-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
executable file
·38 lines (33 loc) · 1.28 KB
/
main.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env nextflow
params.logFC = 1
params.FDR = 0.05
process differentialAnalysis {
input:
path countFile
output:
path 'analysis_results.xlsx'
script:
"""
#!/usr/bin/env R -e "\
library(edgeR); \
library(openxlsx); \
countTable <- read.table('$countFile', header = TRUE, as.is = TRUE, row.names = 1, sep = '\\t'); \
dge <- DGEList(countTable); \
dge <- calcNormFactors(dge); \
treatment = factor(rep(c('CHIR', 'CTRL'), each = 3)); \
pairs <- factor(rep(c('A', 'B', 'C'), 2)); \
designDF <- data.frame(Treatment = treatment, Pair = pairs); \
design <- model.matrix(~ 0 + Treatment + Pair, data = designDF); \
dge <- estimateDisp(dge, design, robust = TRUE); \
fit <- glmQLFit(dge, design, robust = TRUE); \
contrastMat <- makeContrasts(TreatmentVsControl = TreatmentCHIR - TreatmentCTRL, levels = design); \
qlfRes <- glmQLFTest(fit, contrast = contrastMat); \
topRes <- topTags(qlfRes, n = nrow(fit[['counts']])); \
topRes <- subset(topRes[['table']], abs(logFC) > ${params.logFC} & FDR < ${params.FDR}); \
write.xlsx(topRes, 'analysis_results.xlsx', rowNames = TRUE); "
"""
}
workflow {
inputFile = Channel.fromPath(params.input)
differentialAnalysis(inputFile)
}