Skip to content

Commit

Permalink
Merge pull request #20 from bioinform/fix_diff
Browse files Browse the repository at this point in the history
Fix diff
  • Loading branch information
msahraeian authored Nov 11, 2020
2 parents 4c8a60f + a958a9b commit 9a4ddee
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 73 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:18.04


ENV RNACOCKTAIL_VERSION 0.3.1
ENV RNACOCKTAIL_VERSION 0.3.2
ENV R_VERSION 3.6.1-3bionic
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
Expand Down
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ <h2>Publication</h2>

<h2>Download RNACocktail</h2>

<p>Latest version: <a href="https://github.com/bioinform/RNACocktail/archive/v0.3.1.tar.gz"
onclick="trackOutboundLink('https://github.com/bioinform/RNACocktail/archive/v0.3.1.tar.gz'); return false;">https://github.com/bioinform/RNACocktail/archive/v0.3.1.tar.gz</a></p>
<p>Latest version: <a href="https://github.com/bioinform/RNACocktail/archive/v0.3.2.tar.gz"
onclick="trackOutboundLink('https://github.com/bioinform/RNACocktail/archive/v0.3.2.tar.gz'); return false;">https://github.com/bioinform/RNACocktail/archive/v0.3.2.tar.gz</a></p>

<p>For other versions, see "releases". <a href="https://github.com/bioinform/RNACocktail/releases"
onclick="trackOutboundLink('https://github.com/bioinform/RNACocktail/releases'); return false;">https://github.com/bioinform/RNACocktail/releases</a></p>
Expand Down Expand Up @@ -386,8 +386,8 @@ <h2>System Requirements</h2>
</p>

<h2>Installing RNACocktail</h2>
<p>RNACocktail is a Python 2.7 package and can be installed using <code>pip</code>. To install type <code>pip install https://github.com/bioinform/RNACocktail/archive/v0.3.1.tar.gz</code> (using Python 2.7). The current version
of RNACocktail is v0.3.1. In general, the install source would be https://github.com/bioinform/RNACocktail/archive/version.tar.gz</p>
<p>RNACocktail is a Python 2.7 package and can be installed using <code>pip</code>. To install type <code>pip install https://github.com/bioinform/RNACocktail/archive/v0.3.2.tar.gz</code> (using Python 2.7). The current version
of RNACocktail is v0.3.2. In general, the install source would be https://github.com/bioinform/RNACocktail/archive/version.tar.gz</p>


<h2>Running RNACocktail</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.1"
__version__ = "0.3.2"
95 changes: 67 additions & 28 deletions src/run_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from defaults import *
from utils import *
import csv
import glob

FORMAT = '%(levelname)s %(asctime)-15s %(name)-20s %(message)s'
logFormatter = logging.Formatter(FORMAT)
Expand Down Expand Up @@ -182,6 +183,7 @@ def run_deseq2(quant_files="", alignments="",
if start<=step:
logger.info("--------------------------STEP %s--------------------------"%step)
command = "%s -e \"library('DESeq2'); load('%s/txi.rda'); \
samples <- c(%s); \
condition <- factor(c(%s)); \
(colData <- data.frame(row.names=colnames(txi$count), condition));\
counts <- round(txi$counts); mode(counts) <- 'integer'; \
Expand All @@ -193,12 +195,24 @@ def run_deseq2(quant_files="", alignments="",
lengths <- txi$length; dimnames(lengths) <- dimnames(dds);\
assays(dds)[['avgTxLength']] <- lengths; }; \
dds <- dds[ rowSums(counts(dds)) >= %d, ]; \
dds$condition <- relevel(dds$condition, ref='C1'); \
dds <- DESeq(dds); res <- results(dds, alpha=%f); \
(summary(res)); save(txi,colData,condition,dds,res, \
file='%s/deseq2.rda'); write.table(res, file = '%s/deseq2_res.tab', \
quote = FALSE, sep='\\t');\""%(
R, work_deseq2, ",".join(map(lambda i:"rep('C%d', %d)"%(i,n_replicates[i]),range(len(samples)))),
dds <- DESeq(dds); \
for (i in seq_along(samples)){ \
for (j in seq_along(samples)){ \
if (i < j){\
sample1 <- samples[i]; \
sample2 <- samples[j]; \
res <- results(dds, contrast=c('condition',sample1,sample2), alpha=%f); \
(summary(res)); \
res_file= sprintf('%s/deseq2_res_%%s_vs_%%s.tab',sample1,sample2);\
write.table(res, file = res_file, \
quote = FALSE, sep='\\t'); \
} \
} \
}; \
save(txi,colData,condition,dds,res, \
file='%s/deseq2.rda');\""%(
R, work_deseq2, ",".join(map(lambda i:"'sample%d'"%(i),range(len(samples)))),
",".join(map(lambda i:"rep('sample%d', %d)"%(i,n_replicates[i]),range(len(samples)))),
mincount, alpha, work_deseq2, work_deseq2)
cmd = TimedExternalCmd(command, logger, raise_exception=True)
retcode = cmd.run(cmd_log_fd_out=deseq2_log_fd, cmd_log=deseq2_log, msg=msg, timeout=timeout)
Expand Down Expand Up @@ -233,17 +247,29 @@ def run_deseq2(quant_files="", alignments="",
command = "%s -e \"library('DESeq2'); countData <- read.table('%s/featureCounts.txt', \
header=TRUE, row.names=1); countData <- countData[ ,6:ncol(countData)]; \
countData <- as.matrix(countData); \
samples <- c(%s); \
condition <- factor(c(%s)); \
(colData <- data.frame(row.names=colnames(countData), condition));\
dds <- DESeqDataSetFromMatrix(countData=countData, colData=colData, design=~ condition);\
dds <- dds[ rowSums(counts(dds)) >= %d, ]; \
dds$condition <- relevel(dds$condition, ref='C1'); \
dds <- DESeq(dds); res <- results(dds, alpha=%f); \
(summary(res)); save(countData,colData,condition,dds,res, \
file='%s/deseq2.rda'); write.table(res, file = '%s/deseq2_res.tab', \
quote = FALSE, sep='\\t');\""%(
R, work_deseq2, ",".join(map(lambda i:"rep('C%d', %d)"%(i,n_replicates[i]),
range(len(samples)))),
dds <- DESeq(dds); \
for (i in seq_along(samples)){ \
for (j in seq_along(samples)){ \
if (i < j){\
sample1 <- samples[i]; \
sample2 <- samples[j]; \
res <- results(dds, contrast=c('condition',sample1,sample2), alpha=%f); \
(summary(res)); \
res_file= sprintf('%s/deseq2_res_%%s_vs_%%s.tab',sample1,sample2);\
write.table(res, file = res_file, \
quote = FALSE, sep='\\t'); \
} \
} \
}; \
save(countData,colData,condition,dds,res, \
file='%s/deseq2.rda');\""%(
R, work_deseq2, ",".join(map(lambda i:"'sample%d'"%(i),range(len(samples)))),
",".join(map(lambda i:"rep('sample%d', %d)"%(i,n_replicates[i]),range(len(samples)))),
mincount, alpha, work_deseq2, work_deseq2)
cmd = TimedExternalCmd(command, logger, raise_exception=True)
retcode = cmd.run(cmd_log_fd_out=deseq2_log_fd, cmd_log=deseq2_log, msg=msg, timeout=timeout)
Expand Down Expand Up @@ -299,17 +325,29 @@ def run_deseq2(quant_files="", alignments="",
command = "%s -e \"library('DESeq2'); countData <- read.table('%s/featureCounts.txt', \
header=TRUE, row.names=1); countData <- countData[ ,6:ncol(countData)]; \
countData <- as.matrix(countData); \
samples <- c(%s); \
condition <- factor(c(%s)); \
(colData <- data.frame(row.names=colnames(countData), condition));\
dds <- DESeqDataSetFromMatrix(countData=countData, colData=colData, design=~ condition);\
dds <- dds[ rowSums(counts(dds)) >= %d, ]; \
dds$condition <- relevel(dds$condition, ref='C1'); \
dds <- DESeq(dds); res <- results(dds, alpha=%f); \
(summary(res)); save(countData,colData,condition,dds,res, \
file='%s/deseq2.rda'); write.table(res, file = '%s/deseq2_res.tab', \
quote = FALSE, sep='\\t');\""%(
R, work_deseq2, ",".join(map(lambda i:"rep('C%d', %d)"%(i,n_replicates[i]),
range(len(samples)))),
dds <- DESeq(dds); \
for (i in seq_along(samples)){ \
for (j in seq_along(samples)){ \
if (i < j){\
sample1 <- samples[i]; \
sample2 <- samples[j]; \
res <- results(dds, contrast=c('condition',sample1,sample2), alpha=%f); \
(summary(res)); \
res_file= sprintf('%s/deseq2_res_%%s_vs_%%s.tab',sample1,sample2);\
write.table(res, file = res_file, \
quote = FALSE, sep='\\t'); \
} \
} \
}; \
save(countData,colData,condition,dds, \
file='%s/deseq2.rda');\""%(
R, work_deseq2, ",".join(map(lambda i:"'sample%d'"%(i),range(len(samples)))),
",".join(map(lambda i:"rep('sample%d', %d)"%(i,n_replicates[i]),range(len(samples)))),
mincount, alpha, work_deseq2, work_deseq2)
cmd = TimedExternalCmd(command, logger, raise_exception=True)
retcode = cmd.run(cmd_log_fd_out=deseq2_log_fd, cmd_log=deseq2_log, msg=msg, timeout=timeout)
Expand All @@ -322,20 +360,21 @@ def run_deseq2(quant_files="", alignments="",
msg="Copy predictions to output directory for %s."%samples_txt
if start<=step:
logger.info("--------------------------STEP %s--------------------------"%step)
if os.path.exists("%s/deseq2_res.tab"%work_deseq2):
command = "cp %s/deseq2_res.tab %s/deseq2_res.tab"%(
work_deseq2, out_deseq2)
cmd = TimedExternalCmd(command, logger, raise_exception=True)
retcode = cmd.run(cmd_log_fd_out=deseq2_log_fd, cmd_log=deseq2_log, msg=msg, timeout=timeout)
if len(glob.glob("%s/deseq2_res*.tab"%work_deseq2))>0:
for out_file in glob.glob("%s/deseq2_res*.tab"%work_deseq2):
command = "cp %s %s/"%(
out_file, out_deseq2)
cmd = TimedExternalCmd(command, logger, raise_exception=True)
retcode = cmd.run(cmd_log_fd_out=deseq2_log_fd, cmd_log=deseq2_log, msg=msg, timeout=timeout)
else:
logger.info("Skipping step %d: %s"%(step,msg))
step+=1

diff = ""
if os.path.exists("%s/deseq2_res.tab"%out_deseq2):
if len(glob.glob("%s/deseq2_res*.tab"%out_deseq2))>0:
logger.info("DESeq2 was successfull!")
logger.info("Output differential expressions: %s/deseq2_res.tab"%out_deseq2)
diff = "%s/deseq2_res.tab"%out_deseq2
logger.info("Output differential expressions: %s"%(glob.glob("%s/deseq2_res*.tab"%out_deseq2)))
diff = glob.glob("%s/deseq2_res*.tab"%out_deseq2)
else:
logger.info("DESeq2 failed!")
return diff
Expand Down
Loading

0 comments on commit 9a4ddee

Please sign in to comment.