Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Specifying the categories of the bargraph
keys = OrderedDict()
keys = ['AC', 'AG', 'AT', 'CG', 'CT', 'GT', 'Ts', 'Tv']
pconfig = {
'id': 'vcftools_tstv_summary',
'title': 'VCFTools: TsTv Summary',
'ylab': 'Counts',
}
self.add_section(
name = 'TsTv Summary',
anchor = 'vcftools-tstv-summary',
description = "Plot of `TSTV-SUMMARY` - count of different types of transition and transversion SNPs.",
plot = bargraph.plot(self.vcftools_tstv_summary,keys,pconfig)
)
return len(self.vcftools_tstv_summary)
""" Make the HighCharts HTML to plot the alignment rates """
# Specify the order of the different possible categories
keys = OrderedDict()
keys['pseudoaligned_reads'] = { 'color': '#437bb1', 'name': 'Pseudoaligned' }
keys['not_pseudoaligned_reads'] = { 'color': '#b1084c', 'name': 'Not aligned' }
# Config for the plot
config = {
'id': 'kallisto_alignment',
'title': 'Kallisto: Alignment Scores',
'ylab': '# Reads',
'cpswitch_counts_label': 'Number of Reads'
}
return bargraph.plot(self.kallisto_data, keys, config)
keys['bad_reads_with_bad_overlap'] = { 'name': 'Bad Overlap' }
keys['bad_reads_with_bad_read_length'] = { 'name': 'Bad Read Length' }
keys['bad_reads_with_low_quality'] = { 'name': 'Low Quality' }
keys['bad_reads_with_polyX'] = { 'name': 'PolyX' }
keys['bad_reads_with_reads_in_bubble'] = { 'name': 'Reads In Bubble' }
keys['bad_reads_with_too_many_N'] = { 'name': 'Too many N' }
# Config for the plot
pconfig = {
'id': 'afterqc_bad_reads_plot',
'title': 'AfterQC: Filtered Reads',
'ylab': '# Reads',
'cpswitch_counts_label': 'Number of Reads',
'hide_zero_cats': False,
}
return bargraph.plot(self.afterqc_data, keys, pconfig)
cats_pec['singleton_m2'] = {'name': 'Singleton R2'}
if self.__any_collapsed:
cats_pec['full-length_cp'] = {'name': 'Full-length Collapsed Pairs'}
cats_pec['truncated_cp'] = {'name': 'Truncated Collapsed Pairs'}
cats_pec['discarded_m1'] = {'name': 'Discarded R1'}
if self.__any_paired:
cats_pec['discarded_m2'] = {'name': 'Discarded R2'}
self.add_section(
name='Retained and Discarded Paired-End Collapsed',
anchor='adapter_removal_retained_plot',
description='The number of retained and discarded reads.',
plot=bargraph.plot(self.adapter_removal_data, cats_pec, pconfig)
)
# kingdom:
keys['metazoa'] = {'color': 'green', 'name': 'Metazoa'}
keys['fungi'] = {'color': 'purple', 'name': 'Fungi'}
# others
keys['unclassified'] = {'color': 'grey', 'name': 'Unclassified'}
keys['others'] = {'color': 'blue', 'name': 'Others'}
# subkingdom
#keys['viridiplantae'] = {'color': 'yellow', 'name': 'Viridiplantae'}
#keys['dikarya'] = {'color': 'brown', 'name': 'dikarya'}
self.add_section(
name = 'Taxonomy by kingdom',
anchor = 'taxonomy',
description = 'The following barplots summarizes the kraken analysis for each sample. ',
helptext = "",
plot = bargraph.plot(data, keys, pconfig))
def chart_align_strand(self):
# mapping strand distribution
pd1 = {}
pd2 = {}
for sid, dd in self.mdata['align_strand'].items():
pd1[sid] = dd['read1']
pd2[sid] = dd['read2']
self.add_section(
name='Mapping Strand Distribution',
anchor='biscuit-strands',
description = "This plot shows the distribution of strand of mapping and strand of bisulfite conversion.",
helptext="Most bisulfite libraries has read 1 goes to parent `++` or `--` and read 2 goes to daughter/synthesized `+-` or `-+`. PBAT or most single-cell/low input libraries typically don't observe this rule.",
plot = bargraph.plot([pd1, pd2],
[OrderedDict([
('++', {'name':'++: Waston-Aligned, Waston-Bisulfite Conversion', 'color': '#F53855'}),
('+-', {'name':'+-: Waston-Aligned, Crick-Bisulfite Conversion', 'color': '#E37B40'}),
('-+', {'name':'-+: Crick-Aligned, Waston-Bisulfite Conversion', 'color': '#46B29D'}),
('--', {'name':'--: Crick-Aligned, Crick-Bisulfite Conversion', 'color': '#324D5C'}),]),
OrderedDict([
('++', {'name':'++: Waston-Aligned, Waston-Bisulfite Conversion', 'color': '#F53855'}),
('+-', {'name':'+-: Waston-Aligned, Crick-Bisulfite Conversion', 'color': '#E37B40'}),
('-+', {'name':'-+: Crick-Aligned, Waston-Bisulfite Conversion', 'color': '#46B29D'}),
('--', {'name':'--: Crick-Aligned, Crick-Bisulfite Conversion', 'color': '#324D5C'})])],
{'id':'biscuit_strands',
'title':'BISCUIT: Mapping Strand Distribution',
'ylab':'Number of Reads',
'cpswitch_c_active': True,
'cpswitch_counts_label': '# Reads',
'data_labels': [
keys = OrderedDict()
keys['reads_mirna'] = { 'color': '#33a02c', 'name': 'miRNA' }
keys['reads_rrna'] = { 'color': '#ff7f00', 'name': 'rRNA' }
keys['reads_trna'] = { 'color': '#1f78b4', 'name': 'tRNA' }
keys['reads_artifact'] = { 'color': '#fb9a99', 'name': 'Artifact' }
keys['reads_unknown'] = { 'color': '#d9d9d9', 'name': 'Unknown' }
# Config for the plot
config = {
'id': 'mirtrace_rna_categories_plot',
'title': 'miRTrace: RNA Categories',
'ylab': '# Reads',
'cpswitch_counts_label': 'Number of Reads'
}
return bargraph.plot(self.summary_data, keys, config)
pconfig = {
'id': 'rseqc_junction_annotation_junctions_plot',
'title': 'RSeQC: Splicing Junctions',
'ylab': '% Junctions',
'cpswitch_c_active': False,
'data_labels': [ 'Junctions', 'Events' ]
}
self.add_section (
name = 'Junction Annotation',
anchor = 'rseqc_junction_annotation',
description = '<a href="http://rseqc.sourceforge.net/#junction-annotation-py">Junction annotation</a>' \
" compares detected splice junctions to" \
" a reference gene model. An RNA read can be spliced 2" \
" or more times, each time is called a splicing event.",
plot = bargraph.plot([self.junction_annotation_data, self.junction_annotation_data], keys, pconfig)
)
# Return number of samples found
return len(self.junction_annotation_data)
for sample in self.sortmerna:
for key in self.sortmerna[sample]:
if not key in ["total", "rRNA", "non_rRNA"] and not "_pct" in key:
metrics.add(key)
for key in metrics:
keys[key] = { 'name': key.replace("_count","") }
# Config for the plot
pconfig = {
'id': 'sortmerna-detailed-plot',
'title': 'SortMeRNA: Hit Counts',
'ylab': 'Reads'
}
self.add_section( plot = bargraph.plot(self.sortmerna, keys, pconfig) )
keys['N_unmapped'] = { 'color': '#7f0000', 'name': 'Unmapped' }
# Config for the plot
pconfig = {
'id': 'star_gene_counts',
'title': 'STAR: Gene Counts',
'ylab': '# Reads',
'cpswitch_counts_label': 'Number of Reads',
'data_labels': ['Unstranded','Same Stranded','Reverse Stranded']
}
datasets = [
self.star_genecounts_unstranded,
self.star_genecounts_first_strand,
self.star_genecounts_second_strand
]
return bargraph.plot(datasets, [keys,keys,keys,keys], pconfig)