Skip to content

Commit 742f693

Browse files
author
Peter Combs
committed
Merge branch 'BcdRNAi'
2 parents c8d17ba + d55d5a4 commit 742f693

4 files changed

Lines changed: 46 additions & 19 deletions

File tree

MakeSummaryTable.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,17 @@ def get_stagenum(name, series, dir):
142142
reads = 0
143143
for read in sf:
144144
reads += not read.is_secondary
145-
if reads > args.strip_low_reads and not args.strip_low_map_rate:
145+
if ((reads > args.strip_low_reads)
146+
and not args.strip_low_map_rate):
146147
break
147148
skip = reads < args.strip_low_reads
148149
else:
149150
skip = sf.mapped < args.strip_low_reads
150151
if args.strip_low_map_rate and args.has_params and not skip:
151-
rfs = sorted(glob(path.join('sequence',
152-
'*{}*'.format(params.ix[old_dirname]['Index']),
153-
'*_R1_*.fastq.gz'))
154-
)
152+
rfs = [entry for entry in
153+
sf.header['PG'][0]['CL'].split()
154+
if entry.endswith('.gz') or entry.endswith('.fastq')][0]
155+
rfs = sorted(rfs.split(','))
155156
total_reads = 4e6 * (len(rfs) - 1)
156157
for i, line in enumerate(gzip.open(rfs[-1])):
157158
pass

Makefile

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ STARCONFIG = Parameters/STAR_params.in
66
ANALYSIS_DIR = analysis
77

88
# Reference FASTA and GFF files from FlyBase and SGD
9-
MELRELEASE = r6.01_FB2014_04
9+
MELRELEASE = r6.02_FB2014_05
1010
VIRRELEASE = r1.2_FB2012_01
1111
MELMAJORVERSION = $(word 1, $(subst ., , $(MELRELEASE)))
1212
MELVERSION = $(word 1, $(subst _FB, ,$(MELRELEASE)))
@@ -34,6 +34,8 @@ CERGFF = prereqs/saccharomyces_cerevisiae_R64-1-1_20110208.gff
3434
MELVIRGTF= $(REFDIR)/melvir.gtf
3535
MELVIRGTF_FILT= $(REFDIR)/melvir_withgenename.gtf
3636
MELVIRFASTA=$(REFDIR)/melvir.fa
37+
MELALLGTF = $(REFDIR)/mel_all.gtf
38+
MELBADGTF = $(REFDIR)/mel_bad.gtf
3739

3840
GENEMAPTABLE = gene_map_table_fb_$(MELDATE).tsv
3941

@@ -71,8 +73,14 @@ $(ANALYSIS_DIR)/summary.tsv : MakeSummaryTable.py $(FPKMS) $(RUNCONFIG) Makefile
7173
@echo 'Calculating Abundances'
7274
@echo '============================='
7375
touch $@
74-
cufflinks --num-threads 8 --output-dir $(@D) -u \
75-
--frag-bias-correct $(MELFASTA2) -G $(MELGTF) $<
76+
cufflinks \
77+
--num-threads 8 \
78+
--output-dir $(@D) \
79+
--multi-read-correct \
80+
--frag-bias-correct $(MELFASTA2) \
81+
--GTF $(MELGTF) \
82+
--mask-file $(MELBADGTF) \
83+
$<
7684

7785
%/accepted_hits_sorted.bam: %/accepted_hits.bam
7886
touch $@
@@ -92,11 +100,9 @@ $(ANALYSIS_DIR)/summary.tsv : MakeSummaryTable.py $(FPKMS) $(RUNCONFIG) Makefile
92100
rm $(@D)/assigned_dmel_sorted.bam
93101
samtools index $@
94102

95-
96-
$(MELGTF): $(MELGFF) | $(REFDIR)
103+
$(MELALLGTF): $(MELGFF) | $(REFDIR)
97104
gffread $< -E -T -o- | \
98-
awk '{print "dmel_"$$0}' | \
99-
grep -vP '(snoRNA|CR[0-9]{4}|Rp[ILS]|mir-|tRNA|unsRNA|snRNA|snmRNA|scaRNA|rRNA|RNA:|mt:)' > \
105+
awk '{print "dmel_"$$0}' > \
100106
$@
101107

102108
$(VIRGTF): $(VIRGFF) $(ORTHOLOGS) | $(REFDIR)
@@ -107,11 +113,22 @@ $(VIRGTF): $(VIRGFF) $(ORTHOLOGS) | $(REFDIR)
107113
| python FilterOrthologs.py $(ORTHOLOGS) \
108114
> $@
109115

116+
$(MELGTF): $(MELALLGTF) | $(REFDIR)
117+
cat $< \
118+
| grep -vP '(snoRNA|CR[0-9]{4}|Rp[ILS]|mir-|tRNA|unsRNA|snRNA|snmRNA|scaRNA|rRNA|RNA:|mt:)' \
119+
> $@
120+
121+
$(MELBADGTF): $(MELALLGTF) | $(REFDIR)
122+
cat $< \
123+
| grep -P '(snoRNA|CR[0-9]{4}|Rp[ILS]|mir-|tRNA|unsRNA|snRNA|snmRNA|scaRNA|rRNA|RNA:|mt:)' \
124+
> $@
125+
126+
110127
$(MELFASTA): $(REFDIR)/$(MELMAJORVERSION) | $(REFDIR)
111128
wget -O $@.gz ftp://ftp.flybase.net/genomes/Drosophila_melanogaster/dmel_$(MELRELEASE)/fasta/dmel-all-chromosome-$(MELVERSION).fasta.gz
112129
gunzip --force $@.gz
113130

114-
$(MELGFF): $(REFDIR)/$(MELVERSION) | $(REFDIR)
131+
$(MELGFF): $(REFDIR)/$(MELVERSION) | $(REFDIR)
115132
wget -O $@.gz ftp://ftp.flybase.net/genomes/Drosophila_melanogaster/dmel_$(MELRELEASE)/gff/dmel-all-$(MELVERSION).gff.gz
116133
gunzip --force $@.gz
117134

PlotUtils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
200200
pat = dwg.pattern(id='hatch', insert=(0, 0), size=(25, 25),
201201
patternUnits='userSpaceOnUse')
202202
g = pat.add(dwg.g(style="fill:none; stroke:#B0B0B0; stroke-width:1"))
203-
g.add(dwg.path(('M0,0', 'l25,25')))
204-
g.add(dwg.path(('M25,0 l-25,25'.split())))
203+
g.add(dwg.path(('M0,0', 'l20,20')))
204+
g.add(dwg.path(('M10,0 l10,10'.split())))
205+
g.add(dwg.path(('M0,10 l10,10'.split())))
205206

206207
dwg.add(pat)
207208

@@ -246,6 +247,11 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
246247
norm_data = frame.divide(frame.dropna(axis=1).mean(axis=1), axis=0)
247248
elif normer is 'max':
248249
norm_data = frame.divide(frame.dropna(axis=1).max(axis=1), axis=0)
250+
elif normer is 'center0':
251+
norm_data = (0.5 +
252+
0.5 * frame.divide(frame.dropna(axis=1).abs().max(axis=1),
253+
axis=0)
254+
)
249255
elif index is not None and hasattr(normer, "ix"):
250256
norm_data = frame.divide(normer.ix[index], axis=0)
251257
elif hasattr(normer, "__len__") and len(normer) == rows:
@@ -345,5 +351,5 @@ def svg_heatmap(data, filename, row_labels=None, box_size=4,
345351
if draw_row_labels:
346352
for i in range(rows):
347353
dwg.add(dwg.text(row_labels[i],
348-
(x_start, y_start + i*box_size+box_height),))
354+
(x_start, y_start + i*box_height+box_height),))
349355
dwg.saveas(filename)

configure

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ star_str = ('$(ANALYSIS_DIR)/{label}/accepted_hits.bam: '
3838

3939
mappers = {'star': star_str, 'tophat' : tophat_str}
4040

41-
glob_specs = ['{seqdir}/*/*{label}*/*_{{read}}_*.fastq*',
42-
'{seqdir}/*index{index}/*_{{read}}*.fastq*',
43-
]
41+
glob_specs = [
42+
'{seqdir}/*{label}{index}/*_{{read}}_*.fastq*',
43+
# '{seqdir}/*{index}/*_{{read}}_*.fastq*',
44+
'{seqdir}/*/*{label}*/*_{{read}}_*.fastq*',
45+
'{seqdir}/*index{index}/*_{{read}}*.fastq*',
46+
]
4447

4548

4649
def parse_arguments():

0 commit comments

Comments
 (0)