本文整理汇总了Python中multiqc.plots.bargraph.plot函数的典型用法代码示例。如果您正苦于以下问题:Python plot函数的具体用法?Python plot怎么用?Python plot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了plot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bcbio_mirna_stats
def bcbio_mirna_stats(self):
bcbio_data = list()
fns = self.find_log_files('bcbio/seqbuster')
mirs_data = defaultdict(dict)
mirs_key = OrderedDict()
iso_data = defaultdict(dict)
iso_key = OrderedDict()
for f in fns:
s_name = self.clean_s_name(f['fn'], root=None)
with open(os.path.join(f['root'], f['fn'])) as in_handle:
for line in in_handle:
cols = line.strip().split()
if line.startswith("mirs_"):
mirs_key[cols[0]] = {'name': cols[0].replace("_", " ")}
mirs_data[s_name][cols[0]] = int(cols[1])
if line.startswith("iso_"):
iso_key[cols[0]] = {'name': cols[0].replace("_", " ")}
iso_data[s_name][cols[0]] = int(cols[1])
self.write_data_file(mirs_data, "seqbuster_mirs")
self.write_data_file(iso_data, "seqbuster_isomirs")
if mirs_data:
cnfg = {'ylab': '# of miRNAs'}
cnfg['title'] = "Number of miRNAs with changes"
self.mirs = bargraph.plot(mirs_data, mirs_key, cnfg)
if iso_data:
cnfg = {'ylab': '# of isomiRs'}
cnfg['title'] = "Number of isomiRs with changes"
self.iso = bargraph.plot(iso_data, iso_key, cnfg)
示例2: bowtie2_alignment_plot
def bowtie2_alignment_plot (self):
""" Make the HighCharts HTML to plot the alignment rates """
half_warning = ''
for s_name in self.bowtie2_data:
if 'paired_aligned_mate_one_halved' in self.bowtie2_data[s_name] or 'paired_aligned_mate_multi_halved' in self.bowtie2_data[s_name] or 'paired_aligned_mate_none_halved' in self.bowtie2_data[s_name]:
half_warning = '<em>Please note that single mate alignment counts are halved to tally with pair counts properly.</em>'
description_text = 'This plot shows the number of reads aligning to the reference in different ways.'
# Config for the plot
config = {
'ylab': '# Reads',
'cpswitch_counts_label': 'Number of Reads'
}
# Two plots, don't mix SE with PE
if self.num_se > 0:
sekeys = OrderedDict()
sekeys['unpaired_aligned_one'] = { 'color': '#20568f', 'name': 'SE mapped uniquely' }
sekeys['unpaired_aligned_multi'] = { 'color': '#f7a35c', 'name': 'SE multimapped' }
sekeys['unpaired_aligned_none'] = { 'color': '#981919', 'name': 'SE not aligned' }
config['id'] = 'bowtie2_se_plot'
config['title'] = 'Bowtie 2: SE Alignment Scores'
self.add_section(
description = description_text,
helptext = '''
There are 3 possible types of alignment:
* **SE Mapped uniquely**: Read has only one occurence in the reference genome.
* **SE Multimapped**: Read has multiple occurence.
* **SE No aligned**: Read has no occurence.
''',
plot = bargraph.plot(self.bowtie2_data, sekeys, config)
)
if self.num_pe > 0:
pekeys = OrderedDict()
pekeys['paired_aligned_one'] = { 'color': '#20568f', 'name': 'PE mapped uniquely' }
pekeys['paired_aligned_discord_one'] = { 'color': '#5c94ca', 'name': 'PE mapped discordantly uniquely' }
pekeys['paired_aligned_mate_one_halved'] = { 'color': '#95ceff', 'name': 'PE one mate mapped uniquely' }
pekeys['paired_aligned_multi'] = { 'color': '#f7a35c', 'name': 'PE multimapped' }
pekeys['paired_aligned_discord_multi'] = { 'color': '#dce333', 'name': 'PE discordantly multimapped' }
pekeys['paired_aligned_mate_multi_halved'] = { 'color': '#ffeb75', 'name': 'PE one mate multimapped' }
pekeys['paired_aligned_mate_none_halved'] = { 'color': '#981919', 'name': 'PE neither mate aligned' }
config['id'] = 'bowtie2_pe_plot'
config['title'] = 'Bowtie 2: PE Alignment Scores'
self.add_section(
description = "<br>".join([description_text,half_warning]),
helptext = '''
There are 6 possible types of alignment:
* **PE mapped uniquely**: Pair has only one occurence in the reference genome.
* **PE mapped discordantly uniquely**: Pair has only one occurence but not in proper pair.
* **PE one mate mapped uniquely**: One read of a pair has one occurence.
* **PE multimapped**: Pair has multiple occurence.
* **PE one mate multimapped**: One read of a pair has multiple occurence.
* **PE neither mate aligned**: Pair has no occurence.
''',
plot = bargraph.plot(self.bowtie2_data, pekeys, config)
)
示例3: hisat2_alignment_plot
def hisat2_alignment_plot (self):
""" Make the HighCharts HTML to plot the alignment rates """
# Split the data into SE and PE
sedata = {}
pedata = {}
for s_name, data in self.hisat2_data.items():
if 'paired_total' in data:
# Save half 'pairs' of mate counts
m_keys = ['unpaired_total', 'unpaired_aligned_none', 'unpaired_aligned_one', 'unpaired_aligned_multi']
for k in m_keys:
if k in data:
data[k] = float(data[k]) / 2.0
pedata[s_name] = data
else:
sedata[s_name] = data
# Two plots, don't mix SE with PE
if len(sedata) > 0:
sekeys = OrderedDict()
sekeys['unpaired_aligned_one'] = { 'color': '#20568f', 'name': 'SE mapped uniquely' }
sekeys['unpaired_aligned_multi'] = { 'color': '#f7a35c', 'name': 'SE multimapped' }
sekeys['unpaired_aligned_none'] = { 'color': '#981919', 'name': 'SE not aligned' }
pconfig = {
'id': 'hisat2_se_plot',
'title': 'HISAT2: SE Alignment Scores',
'ylab': '# Reads',
'cpswitch_counts_label': 'Number of Reads'
}
self.add_section(
plot = bargraph.plot(sedata, sekeys, pconfig)
)
if len(pedata) > 0:
pekeys = OrderedDict()
pekeys['paired_aligned_one'] = { 'color': '#20568f', 'name': 'PE mapped uniquely' }
pekeys['paired_aligned_discord_one'] = { 'color': '#5c94ca', 'name': 'PE mapped discordantly uniquely' }
pekeys['unpaired_aligned_one'] = { 'color': '#95ceff', 'name': 'PE one mate mapped uniquely' }
pekeys['paired_aligned_multi'] = { 'color': '#f7a35c', 'name': 'PE multimapped' }
pekeys['unpaired_aligned_multi'] = { 'color': '#ffeb75', 'name': 'PE one mate multimapped' }
pekeys['unpaired_aligned_none'] = { 'color': '#981919', 'name': 'PE neither mate aligned' }
pconfig = {
'id': 'hisat2_pe_plot',
'title': 'HISAT2: PE Alignment Scores',
'ylab': '# Reads',
'cpswitch_counts_label': 'Number of Reads'
}
self.add_section(
description = '<em>Please note that single mate alignment counts are halved to tally with pair counts properly.</em>',
plot = bargraph.plot(pedata, pekeys, pconfig)
)
示例4: bbt_simple_plot
def bbt_simple_plot(self):
""" Makes a simple bar plot with summed alignment counts for
each species, stacked. """
# First, sum the different types of alignment counts
data = OrderedDict()
cats = OrderedDict()
for s_name in self.bbt_data:
data[s_name] = OrderedDict()
for org in self.bbt_data[s_name]:
data[s_name][org] = self.bbt_data[s_name][org]['hits'] - self.bbt_data[s_name][org]['shared']
if org not in cats and org != 'multiMatch' and org != 'noMatch':
if org.lower().endswith('.fa'):
cname = org[:-3]
elif org.lower().endswith('.fasta'):
cname = org[:-6]
else:
cname = org
cats[org] = { 'name': cname }
pconfig = {
'id': 'biobloom_tools',
'title': 'BioBloom Tools: Alignment counts per species',
'ylab': 'Number of hits',
'hide_zero_cats': False
}
cats['multiMatch'] = { 'name': 'Multiple Genomes', 'color': '#820000' }
cats['noMatch'] = { 'name': 'No Match', 'color': '#cccccc' }
return bargraph.plot(data, cats, pconfig)
示例5: summary_plot
def summary_plot(data):
"""Barplot of combined pairs"""
cats = OrderedDict()
cats = {
'inniepairs': {
'name': 'Combined innie pairs',
'color': '#191970'
},
'outiepairs': {
'name': 'Combined outie pairs',
'color': '#00A08A'
},
'uncombopairs': {
'name': 'Uncombined pairs',
'color': '#cd1076'
},
'discardpairs': {
'name': 'Discarded pairs',
'color': '#ffd700'
}
}
splotconfig = {'id': 'flash_combo_stats_plot',
'title': 'FLASh: Read combination statistics',
'ylab': 'Number of read pairs',
'hide_zero_cats': False }
return bargraph.plot(data, cats, splotconfig)
示例6: tag_info_chart
def tag_info_chart (self):
""" Make the taginfo.txt plot """
## TODO: human chrs on hg19. How will this work with GRCh genome or other, non human, genomes?
# nice if they are ordered by size
ucsc = ["chr" + str(i) for i in range(1,23)].append([ "chrX", "chrY", "chrM"])
ensembl = list(range(1,23)).append([ "X", "Y", "MT"])
pconfig = {
'id': 'tagInfo',
'title': 'Homer: Tag Info Distribution',
'ylab': 'Tags',
'cpswitch_counts_label': 'Number of Tags'
}
## check if chromosomes starts with "chr" (UCSC) or "#" (ensembl)
sample1 = next(iter(self.tagdir_data['taginfo_total']))
chrFormat = next(iter(self.tagdir_data['taginfo_total'][sample1]))
if ("chr" in chrFormat):
chrs = ucsc
else:
chrs = ensembl
return bargraph.plot(self.tagdir_data['taginfo_total'], chrs, pconfig)
示例7: hicpro_as_chart
def hicpro_as_chart (self):
""" Generate Allele-specific plot"""
keys = OrderedDict()
keys['Valid_pairs_from_ref_genome_(1-1)'] = { 'color': '#e6550d', 'name': 'Genome1 specific read pairs (1-1)' }
keys['Valid_pairs_from_ref_genome_with_one_unassigned_mate_(0-1/1-0)'] = { 'color': '#fdae6b', 'name': 'Genome1 with one unassigned mate (0-1/1-0)' }
keys['Valid_pairs_from_alt_genome_(2-2)'] = { 'color': '#756bb1', 'name': 'Genome2 specific read pairs (2-2)' }
keys['Valid_pairs_from_alt_genome_with_one_unassigned_mate_(0-2/2-0)'] = { 'color': '#bcbddc', 'name': 'Genome2 with one unassigned mate (0-2/2-0)' }
keys['Valid_pairs_from_alt_and_ref_genome_(1-2/2-1)'] = { 'color': '#a6611a', 'name': 'Trans homologuous read pairs (1-2/2/1)' }
keys['Valid_pairs_with_both_unassigned_mated_(0-0)'] = { 'color': '#cccccc', 'name': 'Unassigned read pairs' }
keys['Valid_pairs_with_at_least_one_conflicting_mate_(3-)'] = { 'color': '#a9a2a2', 'name': 'Conflicting read pairs' }
# check allele-specific analysis was run
num_samples = 0
for s_name in self.hicpro_data:
for k in keys:
num_samples += sum([1 if k in self.hicpro_data[s_name] else 0])
if num_samples == 0:
return False
# Config for the plot
config = {
'id': 'hicpro_asan_plot',
'title': 'HiC-Pro: Allele-specific Statistics',
'ylab': '# Pairs',
'cpswitch_counts_label': 'Number of Pairs'
}
return bargraph.plot(self.hicpro_data, keys, config)
示例8: hicpro_mapping_chart
def hicpro_mapping_chart (self):
""" Generate the HiC-Pro Aligned reads plot """
# Specify the order of the different possible categories
keys = OrderedDict()
keys['Full_Alignments_Read'] = { 'color': '#005ce6', 'name': 'Full reads Alignments' }
keys['Trimmed_Alignments_Read'] = { 'color': '#3385ff', 'name': 'Trimmed reads Alignments' }
keys['Failed_To_Align_Read'] = { 'color': '#a9a2a2', 'name': 'Failed To Align' }
data = [{},{}]
for s_name in self.hicpro_data:
for r in [1,2]:
data[r-1]['{} [R{}]'.format(s_name, r)] = {
'Full_Alignments_Read': self.hicpro_data[s_name]['global_R{}'.format(r)],
'Trimmed_Alignments_Read': self.hicpro_data[s_name]['local_R{}'.format(r)],
'Failed_To_Align_Read': int(self.hicpro_data[s_name]['total_R{}'.format(r)]) - int(self.hicpro_data[s_name]['mapped_R{}'.format(r)])
}
# Config for the plot
config = {
'id': 'hicpro_mapping_stats_plot',
'title': 'HiC-Pro: Mapping Statistics',
'ylab': '# Reads',
'ylab': '# Reads: Read 1',
'data_labels': [
{'name': 'Read 1', 'ylab': '# Reads: Read 1'},
{'name': 'Read 2', 'ylab': '# Reads: Read 2'}
]
}
return bargraph.plot(data, [keys, keys], config)
示例9: hicpro_capture_chart
def hicpro_capture_chart (self):
""" Generate Capture Hi-C plot"""
keys = OrderedDict()
keys['valid_pairs_on_target_cap_cap'] = { 'color': '#0039e6', 'name': 'Capture-Capture interactions' }
keys['valid_pairs_on_target_cap_rep'] = { 'color': '#809fff', 'name': 'Capture-Reporter interactions' }
keys['valid_pairs_off_target'] = { 'color': '#cccccc', 'name': 'Off-target valid pairs' }
# Check capture info are available
num_samples = 0
for s_name in self.hicpro_data:
for k in keys:
num_samples += sum([1 if k in self.hicpro_data[s_name] else 0])
if num_samples == 0:
return False
# Config for the plot
config = {
'id': 'hicpro_cap_plot',
'title': 'HiC-Pro: Capture Statistics',
'ylab': '# Pairs',
'cpswitch_counts_label': 'Number of Pairs'
}
return bargraph.plot(self.hicpro_data, keys, config)
示例10: chart_align_strand
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': [
{'name': 'Read 1', },
{'name': 'Read 2', }]
})
)
示例11: star_genecount_chart
def star_genecount_chart (self):
""" Make a plot for the ReadsPerGene output """
# Specify the order of the different possible categories
keys = OrderedDict()
keys['N_genes'] = { 'color': '#2f7ed8', 'name': 'Overlapping Genes' }
keys['N_noFeature'] = { 'color': '#0d233a', 'name': 'No Feature' }
keys['N_ambiguous'] = { 'color': '#492970', 'name': 'Ambiguous Features' }
keys['N_multimapping'] = { 'color': '#f28f43', 'name': 'Multimapping' }
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)
示例12: theta2_purities_chart
def theta2_purities_chart (self):
""" Make the plot showing alignment rates """
# Specify the order of the different possible categories
keys = OrderedDict()
keys['proportion_germline'] = { 'name': 'Germline' }
keys['proportion_tumour_1'] = { 'name': 'Tumour Subclone 1' }
keys['proportion_tumour_2'] = { 'name': 'Tumour Subclone 2' }
keys['proportion_tumour_3'] = { 'name': 'Tumour Subclone 3' }
keys['proportion_tumour_4'] = { 'name': 'Tumour Subclone 4' }
keys['proportion_tumour_5'] = { 'name': 'Tumour Subclone 5' }
keys['proportion_tumour_gt5'] = { 'name': 'Tumour Subclones > 5' }
# Config for the plot
pconfig = {
'id': 'theta2_purity_plot',
'title': 'THetA2: Tumour Subclone Purities',
'cpswitch': False,
'ymin': 0,
'ymax': 100,
'ylab': '% Purity',
'tt_suffix': '%'
}
return bargraph.plot(self.theta2_data, keys, pconfig)
示例13: adapter_removal_retained_chart
def adapter_removal_retained_chart(self):
pconfig = {
'title': 'Adapter Removal: Discarded Reads',
'id': 'ar_retained_plot',
'ylab': '# Reads',
'hide_zero_cats': False,
'cpswitch_counts_label': 'Number of Reads'
}
cats_pec = OrderedDict()
if self.__any_paired:
cats_pec['retained_reads'] = {'name': 'Retained Read Pairs'}
cats_pec['singleton_m1'] = {'name': 'Singleton R1'}
if self.__any_paired:
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)
)
示例14: bowtie_alignment_plot
def bowtie_alignment_plot (self):
""" Make the HighCharts HTML to plot the alignment rates """
# Specify the order of the different possible categories
keys = OrderedDict()
keys['reads_aligned'] = { 'color': '#8bbc21', 'name': 'Aligned' }
keys['multimapped'] = { 'color': '#2f7ed8', 'name': 'Multimapped' }
keys['not_aligned'] = { 'color': '#0d233a', 'name': 'Not aligned' }
# Config for the plot
config = {
'id': 'bowtie1_alignment',
'title': 'Bowtie 1: Alignment Scores',
'ylab': '# Reads',
'cpswitch_counts_label': 'Number of Reads'
}
self.add_section(
description = 'This plot shows the number of reads aligning to the reference in different ways.',
helptext = '''
There are 3 possible types of alignment:
* **Aligned**: Read has only one occurence in the reference genome.
* **Multimapped**: Read has multiple occurence.
* **Not aligned**: Read has no occurence.
''',
plot = bargraph.plot(self.bowtie_data, keys, config)
)
示例15: parse_samtools_rmdup
def parse_samtools_rmdup(self):
""" Find Samtools rmdup logs and parse their data """
self.samtools_rmdup = dict()
for f in self.find_log_files('samtools/rmdup', filehandles=True):
# Example below:
# [bam_rmdupse_core] 26602816 / 103563641 = 0.2569 in library ' '
dups_regex = "\[bam_rmdups?e?_core\] (\d+) / (\d+) = (\d+\.\d+) in library '(.*)'"
s_name = f['s_name']
for l in f['f']:
match = re.search(dups_regex, l)
if match:
library_name = match.group(4).strip()
if library_name != '':
s_name = library_name
if s_name in self.samtools_rmdup:
log.debug("Duplicate sample name found in {}! Overwriting: {}".format(f['fn'], s_name))
self.add_data_source(f, s_name)
self.samtools_rmdup[s_name] = dict()
self.samtools_rmdup[s_name]['n_dups'] = int(match.group(1))
self.samtools_rmdup[s_name]['n_tot'] = int(match.group(2))
self.samtools_rmdup[s_name]['n_unique'] = int(match.group(2)) - int(match.group(1))
self.samtools_rmdup[s_name]['pct_dups'] = float(match.group(3))*100
# Filter to strip out ignored sample names
self.samtools_rmdup = self.ignore_samples(self.samtools_rmdup)
if len(self.samtools_rmdup) > 0:
# Write parsed report data to a file
self.write_data_file(self.samtools_rmdup, 'multiqc_samtools_rmdup')
# Make a bar plot showing duplicates
keys = OrderedDict()
keys['n_unique'] = {'name': 'Non-duplicated reads'}
keys['n_dups'] = {'name': 'Duplicated reads'}
pconfig = {
'id': 'samtools_rmdup_plot',
'title': 'Samtools rmdup: Duplicate alignments',
'yDecimals': False
}
self.add_section (
name = 'Duplicates removed',
anchor = 'samtools-rmdup',
plot = bargraph.plot(self.samtools_rmdup, keys, pconfig)
)
# Add a column to the General Stats table
# General Stats Table
stats_headers = OrderedDict()
stats_headers['pct_dups'] = {
'title': '% Dups',
'description': 'Percent of duplicate alignments',
'min': 0,
'max': 100,
'suffix': '%',
'scale': 'OrRd'
}
self.general_stats_addcols(self.samtools_rmdup, stats_headers, 'Samtools rmdup')
return len(self.samtools_rmdup)