Skip to content

Commit 8cadcdc

Browse files
committed
minor tweaks
1 parent 20e7aea commit 8cadcdc

File tree

6 files changed

+69
-7
lines changed

6 files changed

+69
-7
lines changed

bin/run_deseq2.R

+40
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,46 @@ create_alldetected <- function(res, counts_data) {
8787
return(as.data.frame(joined_data))
8888
}
8989

90+
#######################################################################################
91+
## Added but not used
92+
prepGroup <- function(conds = NULL, cols = NULL, metadata = NULL, covariates = NULL) {
93+
if (is.null(conds) || is.null(cols)) return (NULL)
94+
coldata <- data.frame(cbind(cols, conds))
95+
coldata$conds <- factor(coldata$conds)
96+
colnames_coldata <- c("libname", "group")
97+
if(!is.null(covariates)){
98+
if(covariates!="NoCovariate"){
99+
sample_column_ind <- which(apply(metadata, 2, function(x) sum(x %in% cols) == length(cols)))
100+
sample_column <- colnames(metadata)[sample_column_ind]
101+
covariates <- metadata[match(cols,metadata[,sample_column]), covariates, drop = FALSE]
102+
for(i in 1:ncol(covariates)){
103+
cur_covariate <- covariates[,i]
104+
cur_covariate <- factor(cur_covariate)
105+
coldata <- data.frame(cbind(coldata, cur_covariate))
106+
colnames_coldata <- c(colnames_coldata, paste0("covariate",i))
107+
}
108+
}
109+
}
110+
colnames(coldata) <- colnames_coldata
111+
coldata
112+
}
113+
114+
mrn_normalize <- function(df) {
115+
116+
columns <- colnames(df)
117+
conds <- columns
118+
coldata <- prepGroup(conds, columns)
119+
df[, columns] <- apply(df[, columns], 2,
120+
function(x) as.integer(x))
121+
dds <- DESeqDataSetFromMatrix(countData = as.matrix(df),
122+
colData = coldata, design = ~group)
123+
dds <- estimateSizeFactors(dds)
124+
norm <- counts(dds, normalized=TRUE)
125+
norm_df <- as.data.frame(norm)
126+
return(norm_df)
127+
}
128+
#######################################################################################
129+
90130
filter_and_save_csv <- function(alldetected, foldChange_cutoff, padj_cutoff, direction_change, out_directory_path) {
91131

92132
# Filter rows based on the specified conditions

bin/stage_results.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ for dir in "${sub_dirs[@]}"; do
2020
mkdir -p ${stage_dir}/${dir}
2121
done
2222

23+
# Function to copy directories
24+
copy_deseq_dirs() {
25+
local src_dir="$1"
26+
local dest_dir="$2"
27+
28+
for dir in "$src_dir"/deseq_*; do
29+
if [ -d "$dir" ]; then
30+
cp -r "$dir" "$dest_dir"
31+
fi
32+
done
33+
}
34+
2335

2436
# Stage 00-Overview
2537
cp ${project_results}/overview_report.pdf ${stage_dir}/${sub_dirs[0]}/
@@ -38,7 +50,8 @@ cp ${project_results}/rsem_summary/* ${stage_dir}/${sub_dirs[2]}/
3850
cp ${project_data}/wormbase/*.geneIDs.csv ${stage_dir}/${sub_dirs[2]}/
3951

4052
# Stage 03-Differential_Expression
41-
find "${project_results}" -type d -name "deseq_*" -exec cp -r {} "${stage_dir}/${sub_dirs[3]}/" \;
53+
#find "${project_results}" -type d -name "deseq_*" -exec cp -r {} "${stage_dir}/${sub_dirs[3]}/" \;
54+
copy_deseq_dirs "$project_results" "${stage_dir}/${sub_dirs[3]}"
4255
cp ${project_results}/deseq_report.pdf ${stage_dir}/${sub_dirs[3]}/
4356

4457
# Stage 04-Functional_Analysis

lib/WorkflowUtils.groovy

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class WorkflowUtils {
3131
return retVal
3232
}
3333

34-
34+
public static boolean directoryExists(String path) {
35+
File dir = new File(path);
36+
return dir.exists() && dir.isDirectory();
37+
}
3538

3639
}

modules/fastqc/main.nf

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ process DESEQ_REPORT {
5353
script:
5454
"""
5555
cp -r ${projectDir}/assests/md_to_pdf/* ./results
56+
cp -r ${launchDir}/data/wormbase/*.geneIDs.csv ./results
5657
cp ${report_config} ./results
5758
cd results
5859
deseq_report.py --report-config "${report_config}" --input-path .

nextflow.config

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ process {
2626
}
2727

2828
withLabel:process_low {
29-
queue = 'short'
29+
queue = 'gpu'
3030
memory = '16G'
3131
cpus = '2'
3232
}
3333

3434
withLabel:process_medium {
35-
queue = 'short'
35+
queue = 'gpu'
3636
memory = '24G'
3737
cpus = '4'
3838
}

workflows/00-create-star-rsem-index.nf

+8-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ include { STAR_INDEX } from '../modules/star'
2626
* main script flow
2727
*/
2828
workflow CREATE_STAR_RSEM_INDEX {
29-
GET_WORMBASE_DATA_WF( params.wormbase_version )
30-
STAR_INDEX( GET_WORMBASE_DATA_WF.out.genome_file, GET_WORMBASE_DATA_WF.out.annotation_file )
31-
RSEM_INDEX( GET_WORMBASE_DATA_WF.out.genome_file, GET_WORMBASE_DATA_WF.out.annotation_file )
29+
if(WorkflowUtils.directoryExists("${params.data_dir}/wormbase")){
30+
STAR_INDEX( params.genome_file, params.annotation_file )
31+
RSEM_INDEX( params.genome_file, params.annotation_file )
32+
}else{
33+
GET_WORMBASE_DATA_WF( params.wormbase_version )
34+
STAR_INDEX( GET_WORMBASE_DATA_WF.out.genome_file, GET_WORMBASE_DATA_WF.out.annotation_file )
35+
RSEM_INDEX( GET_WORMBASE_DATA_WF.out.genome_file, GET_WORMBASE_DATA_WF.out.annotation_file )
36+
}
3237

3338
}
3439

0 commit comments

Comments
 (0)