Skip to content

Commit

Permalink
Modify generate gene bed to one script
Browse files Browse the repository at this point in the history
  • Loading branch information
pintoa1-mskcc committed Nov 13, 2024
1 parent e105305 commit fb2f514
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 303 deletions.
120 changes: 0 additions & 120 deletions bin/final_generate_v111_gene_bed.R

This file was deleted.

13 changes: 4 additions & 9 deletions bin/final_generate_v75_gene_bed.R → bin/generate_gene_bed.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ suppressPackageStartupMessages({

usage <- function() {
message("Usage:")
message("final_generate_v75_gene_bed.R <in.gff> <out.bed>")
message("generate_gene_bed.R <in.gff> <out.bed>")
}

args = commandArgs(TRUE)
Expand All @@ -27,13 +27,6 @@ if (length(args)!=2) {
quit()
}

# Utilized gtf from igenomes for FORTE This corresponds to GRCh37 ensembl 75
# Add introns to gtf, convert to gff3
# bsub -R "rusage[mem=64]" -o add_introns_agat_%J.out singularity exec -B /juno/ \\
# -B /tmp -B /scratch/ docker://quay.io/biocontainers/agat:0.8.0--pl5262hdfd78af_0 \\
# /bin/bash -c "agat_sp_add_introns.pl -g /juno/work/taylorlab/cmopipeline/mskcc-igenomes/igenomes/Homo_sapiens/Ensembl/GRCh37/Annotation/Genes/genes.gtf\\
# -o genes.INTRONS.gff3"

gtf <- rtracklayer::import(args[1])
gtf_df <- as.data.frame(gtf)
#remove incomplete transcripts mRNA_end_NF and mRNA_start_NF (not finished)
Expand All @@ -47,7 +40,7 @@ gtf_df <- gtf_df %>%
chr = seqnames
) %>%
select(c(chr, start, end, transcript_id, type, strand, gene_name, gene_id)) %>%
filter(type %in% c("exon","intron","UTR","CDS","cds","utr")) %>%
filter(type %in% c("exon","intron","UTR","CDS","cds","utr","five_prime_utr","three_prime_utr")) %>%
mutate(gene_name = ifelse(is.na(gene_name),gene_id,gene_name)) %>% mutate(start = start-1)


Expand Down Expand Up @@ -110,6 +103,8 @@ modify_transcript <- function(transcript){
transcript$type[transcript$start >= stop_coding & transcript$type == "UTR"] <- "utr5"
}
}
transcript$type[transcript$type == "five_prime_utr"] <- "utr5"
transcript$type[transcript$type == "three_prime_utr"] <- "utr3"
#### Any exon that remains after teh cds change, is likely and untranslated region. change below

# Basically, subfeatures which are "exon" need to be changed (i.e. exon --> utr3/utr5)
Expand Down
63 changes: 19 additions & 44 deletions modules/local/metafusion/genebed/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,30 @@ process METAFUSION_GENEBED {
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
if( prefix == 'GRCh37' )
"""
final_generate_v75_gene_bed.R \\
$gff \\
${prefix}.metafusion.gene.bed
cat <<-END_VERSIONS > versions.yml
"${task.process}":
R: \$(R --version | head -n1)
final_generate_v75_gene_bed.R: 0.0.2
END_VERSIONS
"""

else if( prefix == 'GRCh38' )
"""
final_generate_v111_gene_bed.R \\
$gff \\
${prefix}.metafusion.gene.bed
cat <<-END_VERSIONS > versions.yml
"${task.process}":
R: \$(R --version | head -n1)
final_generate_v111_gene_bed.R: 0.0.1
END_VERSIONS
"""
"""
generate_gene_bed.R \\
$gff \\
${prefix}.metafusion.gene.bed
cat <<-END_VERSIONS > versions.yml
"${task.process}":
R: \$(R --version | head -n1)
generate_gene_bed.R: 0.0.2
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
if( prefix == 'GRCh37' )
"""
touch ${prefix}.metafusion.gene.bed
cat <<-END_VERSIONS > versions.yml
"${task.process}":
R: \$(R --version | head -n1)
final_generate_v75_gene_bed.R: 0.0.2
END_VERSIONS
"""

else if( prefix == 'GRCh38' )
"""
touch ${prefix}.metafusion.gene.bed
"""
touch ${prefix}.metafusion.gene.bed
cat <<-END_VERSIONS > versions.yml
"${task.process}":
R: \$(R --version | head -n1)
final_generate_v111_gene_bed.R: 0.0.1
END_VERSIONS
"""
cat <<-END_VERSIONS > versions.yml
"${task.process}":
R: \$(R --version | head -n1)
generate_gene_bed.R: 0.0.2
END_VERSIONS
"""

}

This file was deleted.

Loading

0 comments on commit fb2f514

Please sign in to comment.