-
Notifications
You must be signed in to change notification settings - Fork 1
Add featurecounts #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yazhinia
wants to merge
25
commits into
sanger-pathogens:dev
Choose a base branch
from
yazhinia:add-features
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
8947c95
featurecounts_args parameters
yazhinia 1dbbbe1
Add featurecounts parameter to nextflow.config
yazhinia 6cc8529
Create featurecounts.nf
yazhinia 68149e9
add featurecounts in module
ba3dc67
add featurecounts module
yazhinia 50df575
add featurecounts params
yazhinia 2ca4b6d
add featurecounts params
yazhinia b0123a5
remove checkpoints
yazhinia c5e80c8
update
yazhinia 672db09
update
yazhinia 47f8944
update
yazhinia 3cb6fd8
update
yazhinia d19ae44
add featurecounts option
yazhinia ba64f64
remove checkpoints
yazhinia c8f64f7
update
yazhinia 18f8277
update
yazhinia f22bb1c
update
yazhinia aa916de
update
yazhinia b3c5c0e
update
yazhinia 4952f7a
update
yazhinia add86ce
update
yazhinia bb3e409
update
yazhinia 0801154
update
yazhinia 6410a70
ignore header lines in gff
yazhinia 884ab2d
rm genes.tmp
yazhinia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -2,4 +2,4 @@ | |
| work/ | ||
| results/ | ||
|
|
||
| .vscode | ||
| .vscode | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,140 @@ | ||
|
|
||
| process FEATURECOUNTS_COUNT { | ||
| tag "${meta.ID} : REP${meta.REP}" | ||
| label 'cpu_1' | ||
| label 'time_1' | ||
| label 'mem_16' | ||
|
|
||
| conda "bioconda::subread=2.1.1" | ||
| container 'quay.io/biocontainers/subread:2.1.1--h577a1d6_0' | ||
|
|
||
| /* | ||
| * Different output folders / patterns | ||
| * - counts tables go to featurecounts/ | ||
| * - any BAM outputs (if added) can go to featurecounts/bam/ | ||
| */ | ||
|
|
||
| publishDir "${params.outdir}/featurecounts", | ||
| mode: 'copy', | ||
| overwrite: true, | ||
| pattern: "*_featurecounts.tsv" | ||
|
|
||
| publishDir "${params.outdir}/featurecounts/bam", | ||
| mode: 'copy', | ||
| overwrite: true, | ||
| pattern: "*_annotated.bam", | ||
| enabled: params.annotate_feature_assignment | ||
|
|
||
| input: | ||
| tuple val(meta), path(mapped_reads), path(annotation) | ||
|
|
||
| output: | ||
| tuple val(meta), path(count_table), emit: sample_feature_counts | ||
| tuple val(meta), path(annotated_bam), optional: true, emit: annotated_bam | ||
|
|
||
| script: | ||
| output_stem = "${meta.ID}_REP${meta.REP}" | ||
| count_table = "${output_stem}_featurecounts.tsv" | ||
| annotated_bam = "${output_stem}_annotated.bam" | ||
|
|
||
| /* | ||
| * Decision on strandedness for featureCounts | ||
| * -s 0 : unstranded | ||
| * -s 1 : forward stranded 5' to 3' | ||
| * -s 2 : reversely stranded 3' to 5' | ||
| */ | ||
|
|
||
| switch (params.library_strandedness) { | ||
| case "none": | ||
| fc_strandedness = "0" | ||
| break | ||
| case "forward": | ||
| fc_strandedness = "1" | ||
| break | ||
| case "reverse": | ||
| fc_strandedness = "2" | ||
| break | ||
| default: | ||
| log.error "Unrecognised parameter value for strandedness: ${params.library_strandedness}" | ||
| } | ||
|
|
||
| if (params.annotate_feature_assignment) { | ||
| """ | ||
| featureCounts \\ | ||
| -a ${annotation} \\ | ||
| -o ${count_table} \\ | ||
| -s ${fc_strandedness} \\ | ||
Lfulcrum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| -T ${task.cpus} \\ | ||
| ${params.featurecounts_args} \\ | ||
| ${mapped_reads} | ||
| cp ${mapped_reads} ${annotated_bam} | ||
| """ | ||
| } else { | ||
| """ | ||
| featureCounts \\ | ||
| -a ${annotation} \\ | ||
| -o ${count_table} \\ | ||
| -s ${fc_strandedness} \\ | ||
| -T ${task.cpus} \\ | ||
| ${params.featurecounts_args} \\ | ||
| ${mapped_reads} | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| process COMBINE_FEATURECOUNTS { | ||
| label 'cpu_1' | ||
| label 'time_1' | ||
| label 'mem_16' | ||
|
|
||
| publishDir "${params.outdir}/featurecounts", mode: 'copy', overwrite: true | ||
|
|
||
| container 'ubuntu:22.04' | ||
|
|
||
| input: | ||
| path(count_tables) | ||
|
|
||
| output: | ||
| path(counts_table), emit: all_feature_counts | ||
|
|
||
| script: | ||
| counts_table = "gene_counts.tsv" | ||
|
|
||
| """ | ||
| files=( *_featurecounts.tsv ) | ||
| # Extract gene list from first count file (column 1) | ||
|
|
||
| if [ \${#files[@]} -eq 0 ]; then | ||
| echo "No *_featurecounts.tsv files found" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Extract sample names from filenames | ||
| samples=() | ||
| for f in "\${files[@]}"; do | ||
| # Remove path + suffix (_featurecounts.tsv) | ||
| base=\$(basename "\$f" | sed 's/_featurecounts.tsv//') | ||
| samples+=( "\$base" ) | ||
| done | ||
|
|
||
| # Write output | ||
| printf "feature_id" > ${counts_table} | ||
|
|
||
| for s in "\${samples[@]}"; do | ||
| printf "\\t%s" "\$s" >> ${counts_table} | ||
| done | ||
| printf "\\n" >> ${counts_table} | ||
|
|
||
| # Build table | ||
| cut -f1 "\${files[0]}" | grep -v '^#' | tail -n +2 | while IFS= read -r gene; do | ||
| printf '%s' "\$gene" | ||
| for f in "\${files[@]}"; do | ||
| count=\$(awk -F'\t' -v g="\$gene" '\$1==g && NR>1 {print \$7; exit}' "\$f") | ||
| printf '\t%s' "\${count:-0}" | ||
| done | ||
| printf '\n' | ||
| done >> "${counts_table}" | ||
|
|
||
| """ | ||
| } | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to also include a new help message into the README after the nextflow_schema.json changes have been made.