Skip to content

Commit

Permalink
final tested commit stage one (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajandria authored Aug 21, 2023
1 parent a756ca6 commit 54248eb
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
75 changes: 75 additions & 0 deletions bin/index-downstream.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env Rscript

# Setup -------------------------------------------------------------------
args <- commandArgs(trailingOnly = TRUE)

downstream_ch_file <- args[1]
organism_in <- args[2]
user_file <- args[3]

if (organism_in == 'mouse') {
organism <- 'mus_musculus'
} else if (organism_in == 'human') {
organism <- 'homo_sapiens'
} else {
stop('Provided organism not supported...')
}

#downstream_ch_file <- "/futuriandgeDownstream/used-locally-for-testing/counts/extended_source-pipeline-out_meta_file-dockerfile.txt"
#organism <- 'mus_musculus'
#user_file <- "/futuriandgeDownstream/used-locally-for-testing/template-user-request.xlsx"

sample_metadata <- readxl::read_excel(user_file, sheet = 'metadata')
contrasts <- readxl::read_excel(user_file, sheet = 'comparisons')

# Load --------------------------------------------------------------------
library(futuriandgeDownstream)

# F1
print('Running futuriandgeDownstream::return_count_matrix')
counts <- futuriandgeDownstream::return_count_matrix(downstream_ch_file)

# F2
print('Running futuriandgeDownstream::remove_mirna')
counts_no_mirnas <- futuriandgeDownstream::remove_mirna(counts, organism)

# F3
print('Running futuriandgeDownstream::run_dge')
dge_results <- futuriandgeDownstream::run_dge(count_matrix_raw = counts_no_mirnas,
metadata_raw = sample_metadata,
comparisons = contrasts)

# save dge results
print('Running save')
save(dge_results, file = 'dge_results.RData')

# F4
print('Running splot_diagnostic_plotsave')
futuriandgeDownstream::plot_diagnostic_plots(count_matrix_raw = counts_no_mirnas,
metadata_raw = sample_metadata)

# F5
print('futuriandgeDownstream::render_dge_html_report')
contrasts_for_report <- dplyr::mutate(contrasts, compared_gorups = paste0(
studied_effect,
'_vs_',
baseline
))

for (groups in contrasts_for_report$compared_gorups) {

sample_metadata$sample <- gsub("_T1",
"",
sample_metadata$sample_id)

futuriandgeDownstream::render_dge_html_report(
comparison_name = groups,
dge_results_in = data.frame(dge_results$dge_results[[groups]]),
metadata = sample_metadata,
norm_counts = dge_results$normalised_counts,
raw_counts = dge_results$raw_counts_no_gtf_miRNA,
organism = organism,
output_name = paste0(groups, ".html")
)
}

5 changes: 5 additions & 0 deletions conf/environments.config
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@
container = 'https://depot.galaxyproject.org/singularity/multiqc:1.14--pyhdfd78af_0'
}

withName: DESEQ2 {
container = 'sodzier/r-pkg-futuriandge-downstream:0.1.0'
containerOptions = "-B ${baseDir}/.nextflow:/futuriandgeDownstream"
}

}
6 changes: 6 additions & 0 deletions modules/local/downstream_processing.nf
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ process DESEQ2 {
output:
path("*"), emit: DESeq2_DOWNSTREAM_out

script:
def org = params.organism
def user_file = params.contrasts
"""
# Merge all downstream info files
cat *_downstream_info.txt > all_downstream_info.txt
# Remove lines containing the header except for the first occurrence in the first line
sed -i '1!{/sample_id,is_single_end,strandedness,count_matrix_path/d}' all_downstream_info.txt
index-downstream.R all_downstream_info.txt ${org} ${user_file}
"""
}
2 changes: 1 addition & 1 deletion modules/local/subread.nf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ process FEATURECOUNTS {
echo "sample_id,is_single_end,strandedness,count_matrix_path" > ${meta.id}_downstream_info.txt
# Write sample info to file
echo "${meta.id},${meta.single_end},${meta.strandedness},${PWD}/${meta.id}_featureCounts_matrix.txt" >> ${meta.id}_downstream_info.txt
echo "${meta.id},${meta.single_end},${meta.strandedness},\$PWD/${meta.id}_featureCounts_matrix.txt" >> ${meta.id}_downstream_info.txt
"""
}

0 comments on commit 54248eb

Please sign in to comment.