-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
286 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/local/bin/Rscript | ||
|
||
# __author__ = "Anne Marie Noronha" | ||
# __email__ = "noronhaa@mskcc.org" | ||
# __version__ = "0.0.1" | ||
|
||
usage <- function() { | ||
message("Usage:") | ||
message("count_features.R --abundance <abundance.tsv> --gtf <annotation.gtf> --sample <sampleid>") | ||
} | ||
|
||
args = commandArgs(TRUE) | ||
|
||
if (is.null(args) | length(args)<1) { | ||
usage() | ||
quit() | ||
} | ||
|
||
#' Parse out options from a string without recourse to optparse | ||
#' | ||
#' @param x Long-form argument list like --opt1 val1 --opt2 val2 | ||
#' | ||
#' @return named list of options and values similar to optparse | ||
|
||
parse_args <- function(x){ | ||
args_list <- unlist(strsplit(x, ' ?--')[[1]])[-1] | ||
args_vals <- lapply(args_list, function(x) scan(text=x, what='character', quiet = TRUE)) | ||
# Ensure the option vectors are length 2 (key/ value) to catch empty ones | ||
args_vals <- lapply(args_vals, function(z){ length(z) <- 2; z}) | ||
|
||
parsed_args <- structure(lapply(args_vals, function(x) x[2]), names = lapply(args_vals, function(x) gsub('-','_',x[1]))) | ||
parsed_args[! is.na(parsed_args)] | ||
} | ||
|
||
args_opt <- parse_args(paste(args,collapse=" ")) | ||
|
||
abundance <- read.table(args_opt$abundance, header=T) | ||
gtf <- args_opt$gtf | ||
Sample <- args_opt$sample | ||
|
||
gtf_df <- as.data.frame(rtracklayer::import(gtf)) | ||
|
||
gtf_df <- unique(gtf_df[,c("transcript_id","gene_id")]) | ||
|
||
abundance <- merge( | ||
abundance, | ||
gtf_df, | ||
by.x="target_id", | ||
by.y="transcript_id", | ||
all.x = T, | ||
all.y =F | ||
) | ||
TranscriptCount <- dim(abundance[abundance$est_counts > 0,])[[1]] | ||
|
||
abundance_gene <- aggregate( | ||
x = abundance$est_counts, | ||
by = list(abundance$gene_id), | ||
FUN = sum | ||
) | ||
GeneCount <- dim(abundance_gene[abundance_gene$x > 0,])[[1]] | ||
|
||
out_df <- data.frame(Sample, TranscriptCount, GeneCount) | ||
write.table( | ||
out_df, | ||
paste0(Sample,".kallisto.customsummary.txt"), | ||
sep="\t", | ||
row.names = F, | ||
append = F, | ||
quote = F | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
process COUNT_FEATURES { | ||
tag "$meta.id" | ||
label "process_low" | ||
|
||
/// must be using singularity 3.7+ | ||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
'https://depot.galaxyproject.org/singularity/bioconductor-rtracklayer:1.60.0--r43ha9d7317_0' : | ||
'https://depot.galaxyproject.org/singularity/bioconductor-rtracklayer:1.60.0--r43ha9d7317_0' }" | ||
|
||
input: | ||
tuple val(meta), path(abundance) | ||
path(gtf) | ||
|
||
output: | ||
tuple val(meta), path("*.kallisto.customsummary.txt"), emit: kallisto_count_feature | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
def sample = "${meta.sample}" | ||
""" | ||
count_features.R \\ | ||
--abundance ${abundance} \\ | ||
--gtf ${gtf} \\ | ||
--sample ${sample} | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
R: \$(R --version | head -n1) | ||
count_features.R: 0.0.1 | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def sample = meta.sample ?: '' | ||
""" | ||
touch ${sample}.kallisto.customsummary.txt | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
R: \$(R --version | head -n1) | ||
add_flags_and_cluster_information.R: 0.0.1 | ||
END_VERSIONS | ||
""" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
modules/nf-core/subread/featurecounts/subread-featurecounts.diff
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters