本文整理汇总了Python中multiqc.plots.linegraph.plot函数的典型用法代码示例。如果您正苦于以下问题:Python plot函数的具体用法?Python plot怎么用?Python plot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了plot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: threeprime_plot
def threeprime_plot(self):
"""Generate a 3' G>A linegraph plot"""
data = dict()
dict_to_add = dict()
# Create tuples out of entries
for key in self.threepGtoAfreq_data:
pos = list(range(1,len(self.threepGtoAfreq_data.get(key))))
#Multiply values by 100 to get %
tmp = [i * 100.0 for i in self.threepGtoAfreq_data.get(key)]
tuples = list(zip(pos,tmp))
# Get a dictionary out of it
data = dict((x, y) for x, y in tuples)
dict_to_add[key] = data
config = {
'id': 'threeprime_misinc_plot',
'title': 'DamageProfiler: 3P G>A misincorporation plot',
'ylab': '% G to A substituted',
'xlab': 'Nucleotide position from 3\'',
'tt_label': '{point.y:.2f} % G>A misincorporations at nucleotide position {point.x}',
'ymin': 0,
'xmin': 1
}
return linegraph.plot(dict_to_add,config)
示例2: coverage_lineplot
def coverage_lineplot (self):
""" Make HTML for coverage line plots """
# Add line graph to section
data = list()
data_labels = list()
if len(self.rna_seqc_norm_high_cov) > 0:
data.append(self.rna_seqc_norm_high_cov)
data_labels.append({'name': 'High Expressed'})
if len(self.rna_seqc_norm_medium_cov) > 0:
data.append(self.rna_seqc_norm_medium_cov)
data_labels.append({'name': 'Medium Expressed'})
if len(self.rna_seqc_norm_low_cov) > 0:
data.append(self.rna_seqc_norm_low_cov)
data_labels.append({'name': 'Low Expressed'})
pconfig = {
'id': 'rna_seqc_mean_coverage_plot',
'title': 'RNA-SeQC: Gene Body Coverage',
'ylab': '% Coverage',
'xlab': "Gene Body Percentile (5' -> 3')",
'xmin': 0,
'xmax': 100,
'tt_label': "<strong>{point.x}% from 5'</strong>: {point.y:.2f}",
'data_labels': data_labels
}
if len(data) > 0:
self.add_section (
name = 'Gene Body Coverage',
anchor = 'rseqc-rna_seqc_mean_coverage',
helptext = 'The metrics are calculated across the transcripts with tiered expression levels.',
plot = linegraph.plot(data, pconfig)
)
示例3: __init__
def __init__(self, c_id, mod):
modname = mod['config'].get('section_name', c_id.replace('_', ' ').title())
if modname == '' or modname is None:
modname = 'Custom Content'
# Initialise the parent object
super(MultiqcModule, self).__init__(
name = modname,
anchor = mod['config'].get('section_anchor', c_id),
href = mod['config'].get('section_href'),
info = mod['config'].get('description')
)
pconfig = mod['config'].get('pconfig', {})
if pconfig.get('title') is None:
pconfig['title'] = modname
# Table
if mod['config'].get('plot_type') == 'table':
pconfig['sortRows'] = pconfig.get('sortRows', False)
headers = mod['config'].get('headers')
self.add_section( plot = table.plot(mod['data'], headers, pconfig) )
self.write_data_file( mod['data'], "multiqc_{}".format(modname.lower().replace(' ', '_')) )
# Bar plot
elif mod['config'].get('plot_type') == 'bargraph':
self.add_section( plot = bargraph.plot(mod['data'], mod['config'].get('categories'), pconfig) )
# Line plot
elif mod['config'].get('plot_type') == 'linegraph':
self.add_section( plot = linegraph.plot(mod['data'], pconfig) )
# Scatter plot
elif mod['config'].get('plot_type') == 'scatter':
self.add_section( plot = scatter.plot(mod['data'], pconfig) )
# Heatmap
elif mod['config'].get('plot_type') == 'heatmap':
self.add_section( plot = heatmap.plot(mod['data'], mod['config'].get('xcats'), mod['config'].get('ycats'), pconfig) )
# Beeswarm plot
elif mod['config'].get('plot_type') == 'beeswarm':
self.add_section( plot = beeswarm.plot(mod['data'], pconfig) )
# Raw HTML
elif mod['config'].get('plot_type') == 'html':
self.add_section( content = mod['data'] )
# Raw image file as html
elif mod['config'].get('plot_type') == 'image':
self.add_section( content = mod['data'] )
# Not supplied
elif mod['config'].get('plot_type') == None:
log.warning("Plot type not found for content ID '{}'".format(c_id))
# Not recognised
else:
log.warning("Error - custom content plot type '{}' not recognised for content ID {}".format(mod['config'].get('plot_type'), c_id))
示例4: frequencies_plot
def frequencies_plot(self, xmin=0, xmax=200):
""" Generate the qualities plot """
helptext = '''
A possible way to assess the complexity of a library even in
absence of a reference sequence is to look at the kmer profile of the reads.
The idea is to count all the kmers (_i.e._, sequence of length `k`) that occur
in the reads. In this way it is possible to know how many kmers occur
`1,2,.., N` times and represent this as a plot.
This plot tell us for each x, how many k-mers (y-axis) are present in the
dataset in exactly x-copies.
In an ideal world (no errors in sequencing, no bias, no repeated regions)
this plot should be as close as possible to a gaussian distribution.
In reality we will always see a peak for `x=1` (_i.e._, the errors)
and another peak close to the expected coverage. If the genome is highly
heterozygous a second peak at half of the coverage can be expected.'''
pconfig = {
'id': 'Jellyfish_kmer_plot',
'title': 'Jellyfish: K-mer plot',
'ylab': 'Counts',
'xlab': 'k-mer frequency',
'xDecimals': False,
'xmin': xmin,
'xmax': xmax
}
self.add_section(
anchor = 'jellyfish_kmer_plot',
description = 'The K-mer plot lets you estimate library complexity and coverage from k-mer content.',
helptext = helptext,
plot = linegraph.plot(self.jellyfish_data, pconfig)
)
示例5: cutadapt_length_trimmed_plot
def cutadapt_length_trimmed_plot (self):
""" Generate the trimming length plot """
description = 'This plot shows the number of reads with certain lengths of adapter trimmed. \n\
Obs/Exp shows the raw counts divided by the number expected due to sequencing errors. A defined peak \n\
may be related to adapter length. See the \n\
<a href="http://cutadapt.readthedocs.org/en/latest/guide.html#how-to-read-the-report" target="_blank">cutadapt documentation</a> \n\
for more information on how these numbers are generated.'
pconfig = {
'id': 'cutadapt_plot',
'title': 'Cutadapt: Lengths of Trimmed Sequences',
'ylab': 'Counts',
'xlab': 'Length Trimmed (bp)',
'xDecimals': False,
'ymin': 0,
'tt_label': '<b>{point.x} bp trimmed</b>: {point.y:.0f}',
'data_labels': [{'name': 'Counts', 'ylab': 'Count'},
{'name': 'Obs/Exp', 'ylab': 'Observed / Expected'}]
}
self.add_section(
description = description,
plot = linegraph.plot([self.cutadapt_length_counts, self.cutadapt_length_obsexp], pconfig)
)
示例6: plot_readlengths
def plot_readlengths(self):
pdata = [
{ s_name: d['All reads']['reads'] for s_name,d in self.minionqc_raw_data.items() },
{ s_name: d['All reads']['gigabases'] for s_name,d in self.minionqc_raw_data.items() }
]
pconfig = {
'id': 'minionqc_read_lengths',
'title': 'MinIONQC: Output versus read length',
'categories': True,
'data_labels': [
{'name': 'All reads: Num reads', 'ylab': '# reads'},
{'name': 'All reads: Num gigabases', 'ylab': '# gigabases'}
]
}
for qfilt in list(self.q_threshold_list):
try:
pdata.extend([
{ s_name: d[qfilt]['reads'] for s_name,d in self.minionqc_raw_data.items() },
{ s_name: d[qfilt]['gigabases'] for s_name,d in self.minionqc_raw_data.items() },
])
pconfig['data_labels'].extend([
{'name': '{}: Num reads'.format(qfilt), 'ylab': '# reads'},
{'name': '{}: Num gigabases'.format(qfilt), 'ylab': '# gigabases'},
])
except KeyError:
pass
self.add_section (
name = 'Read length output',
anchor = 'minionqc-read-length-output',
description = 'Number of reads / bp sequenced at given read length thresholds.',
plot = linegraph.plot(pdata, pconfig=pconfig)
)
示例7: chart_retention_dist
def chart_retention_dist(self):
## cytosine retention distribution
mdata_meth = self.mdata['retention_dist']
mdata = self.mdata['retention_dist_byread']
pd = [
mdata_meth,
dict([(sid, dd['CA']) for sid, dd in mdata.items()]),
dict([(sid, dd['CC']) for sid, dd in mdata.items()]),
dict([(sid, dd['CG']) for sid, dd in mdata.items()]),
dict([(sid, dd['CT']) for sid, dd in mdata.items()]),
]
self.add_section(
name = 'Number of Retention Distribution',
anchor = 'biscuit-retention-read',
description = "This plot shows the distribution of the number of retained cytosine in each read, up to 10.",
plot = linegraph.plot(pd, {
'id': 'biscuit_retention_read_cpa',
'xlab': 'Number of Retention within Read',
'title': 'BISCUIT: Retention Distribution',
'data_labels': [
{'name': 'CpG retention', 'ylab': 'Fraction of cytosine in CpG context', 'xlab': 'Retention Level (%)'},
{'name': 'Within-read CpA', 'ylab': 'Number of Reads'},
{'name': 'Within-read CpC', 'ylab': 'Number of Reads'},
{'name': 'Within-read CpG', 'ylab': 'Number of Reads'},
{'name': 'Within-read CpT', 'ylab': 'Number of Reads'},
]})
)
示例8: sequence_quality_plot
def sequence_quality_plot (self):
""" Create the HTML for the phred quality score plot """
data = dict()
for s_name in self.fastqc_data:
try:
data[s_name] = {self.avg_bp_from_range(d['base']): d['mean'] for d in self.fastqc_data[s_name]['per_base_sequence_quality']}
except KeyError:
pass
if len(data) == 0:
log.debug('sequence_quality not found in FastQC reports')
return None
pconfig = {
'id': 'fastqc_per_base_sequence_quality_plot',
'title': 'FastQC: Mean Quality Scores',
'ylab': 'Phred Score',
'xlab': 'Position (bp)',
'ymin': 0,
'xDecimals': False,
'tt_label': '<b>Base {point.x}</b>: {point.y:.2f}',
'colors': self.get_status_cols('per_base_sequence_quality'),
'yPlotBands': [
{'from': 28, 'to': 100, 'color': '#c3e6c3'},
{'from': 20, 'to': 28, 'color': '#e6dcc3'},
{'from': 0, 'to': 20, 'color': '#e6c3c3'},
]
}
self.add_section (
name = 'Sequence Quality Histograms',
anchor = 'fastqc_per_base_sequence_quality',
description = 'The mean quality value across each base position in the read. ' +
'See the <a href="http://www.bioinformatics.babraham.ac.uk/projects/fastqc/Help/3%20Analysis%20Modules/2%20Per%20Base%20Sequence%20Quality.html" target="_blank">FastQC help</a>.',
plot = linegraph.plot(data, pconfig)
)
示例9: mirtrace_complexity_plot
def mirtrace_complexity_plot(self):
""" Generate the miRTrace miRNA Complexity Plot"""
data = dict()
for s_name in self.complexity_data:
try:
data[s_name] = {int(self.complexity_data[s_name][d]) : int(d) for d in self.complexity_data[s_name]}
except KeyError:
pass
if len(data) == 0:
log.debug('No valid data for miRNA complexity')
return None
config = {
'id': 'mirtrace_complexity_plot',
'title': 'miRTrace: miRNA Complexity Plot',
'ylab': 'Distinct miRNA Count',
'xlab': 'Number of Sequencing Reads',
'ymin': 0,
'xmin': 1,
'xDecimals': False,
'tt_label': '<b>Number of Sequencing Reads {point.x}</b>: {point.y} Distinct miRNA Count',
}
return linegraph.plot(data, config)
示例10: mirtrace_length_plot
def mirtrace_length_plot(self):
""" Generate the miRTrace Read Length Distribution"""
data = dict()
for s_name in self.length_data:
try:
data[s_name] = {int(d): int(self.length_data[s_name][d]) for d in self.length_data[s_name]}
except KeyError:
pass
if len(data) == 0:
log.debug('No valid data for read length distribution')
return None
config = {
'id': 'mirtrace_length_plot',
'title': 'miRTrace: Read Length Distribution',
'ylab': 'Read Count',
'xlab': 'Read Lenth (bp)',
'ymin': 0,
'xmin': 0,
'xDecimals': False,
'tt_label': '<b>Read Length (bp) {point.x}</b>: {point.y} Read Count',
'xPlotBands': [
{'from': 40, 'to': 50, 'color': '#ffebd1'},
{'from': 26, 'to': 40, 'color': '#e2f5ff'},
{'from': 18, 'to': 26, 'color': '#e5fce0'},
{'from': 0, 'to': 18, 'color': '#ffffe2'},
]
}
return linegraph.plot(data, config)
示例11: parse_bamPEFragmentSizeDistribution
def parse_bamPEFragmentSizeDistribution(self):
"""Find bamPEFragmentSize output. Supports the --outRawFragmentLengths option"""
self.deeptools_bamPEFragmentSizeDistribution = dict()
for f in self.find_log_files('deeptools/bamPEFragmentSizeDistribution', filehandles=False):
parsed_data = self.parseBamPEFDistributionFile(f)
for k, v in parsed_data.items():
if k in self.deeptools_bamPEFragmentSizeDistribution:
log.warning("Replacing duplicate sample {}.".format(k))
self.deeptools_bamPEFragmentSizeDistribution[k] = v
if len(parsed_data) > 0:
self.add_data_source(f, section='bamPEFragmentSizeDistribution')
if len(self.deeptools_bamPEFragmentSizeDistribution) > 0:
config = {
'id': 'fragment_size_distribution_plot',
'title': 'deeptools: Fragment Size Distribution Plot',
'ylab': 'Occurrence',
'xlab': 'Fragment Size (bp)',
'smooth_points': 50,
'xmax': 1000,
'xDecimals': False,
'tt_label': '<b>Fragment Size (bp) {point.x}</b>: {point.y} Occurrence',
}
self.add_section (
name = 'Fragment size distribution',
anchor = 'fragment_size_distribution',
description="Distribution of paired-end fragment sizes",
plot=linegraph.plot(self.deeptools_bamPEFragmentSizeDistribution, config)
)
return len(self.deeptools_bamPEFragmentSizeDistribution)
示例12: fiveprime_plot
def fiveprime_plot(self):
"""Generate a 5' C>T linegraph plot"""
data = dict()
dict_to_add = dict()
# Create tuples out of entries
for key in self.fivepCtoTfreq_data:
pos = list(range(1,len(self.fivepCtoTfreq_data.get(key))))
tmp = [i * 100.0 for i in self.fivepCtoTfreq_data.get(key)]
tuples = list(zip(pos,tmp))
# Get a dictionary out of it
data = dict((x, y) for x, y in tuples)
dict_to_add[key] = data
config = {
'id': 'fiveprime_misinc_plot',
'title': 'DamageProfiler: 5\' C>T misincorporation plot',
'ylab': '% C to T substituted',
'xlab': 'Nucleotide position from 5\'',
'tt_label': '{point.y:.2f} % C>T misincorporations at nucleotide position {point.x}',
'ymin': 0,
'xmin': 1
}
return linegraph.plot(dict_to_add,config)
示例13: bcbio_coverage_avg_chart_deprecated_in_1_0_6
def bcbio_coverage_avg_chart_deprecated_in_1_0_6(self, names):
""" Make the bcbio assignment rates plot
(from the old-style file before mosdepth integration,
deprectated since bcbio 1.0.6 """
x_threshold = 0
data = defaultdict(dict)
for f in self.find_log_files(names):
s_name = self.clean_s_name(f['fn'], root=None)
for line in f['f'].split("\n"):
if not line.startswith("percentage"):
continue
cutoff_reads, bases_pct, sample = line.split("\t")
y = float(bases_pct)
x = int(cutoff_reads.replace("percentage", ""))
data[s_name][x] = y
if y > 1.0:
x_threshold = max(x_threshold, x)
if s_name in data:
self.add_data_source(f)
if data:
return linegraph.plot(data, {
'xlab': 'Coverage (X)',
"ylab": '% bases in genome or rarget covered by least X reads',
'ymax': 100,
"xmax": x_threshold,
})
示例14: _add_hs_penalty
def _add_hs_penalty(data):
subtitle = "The \"hybrid selection penalty\" incurred to get 80% of target bases to a given coverage. Can be used with the formula <code>required_aligned_bases = bait_size_bp * desired_coverage * hs_penalty</code>."
data_clean = defaultdict(dict)
any_non_zero = False
for s in data:
for h in data[s]:
if h.startswith("HS_PENALTY"):
data_clean[s][(h.replace("HS_PENALTY_", " ")[:-1])] = data[s][h]
if data[s][h] > 0:
any_non_zero = True
pconfig = { 'id': 'picard_hybrid_selection_penalty',
'title': 'Picard: Hybrid Selection Penalty',
'xlab': 'Fold Coverage',
'ylab': 'Pct of bases',
'ymax': 100,
'ymin': 0,
'xmin': 0,
'tt_label': '<b>{point.x}X</b>: {point.y:.2f}%',}
if any_non_zero:
return {
'name': 'HS penalty',
'anchor': 'picard_hsmetrics_hs_penalty',
'description': subtitle,
'plot': linegraph.plot(data_clean, pconfig)
}
示例15: _bcbio_umi_count_plot
def _bcbio_umi_count_plot(self, parsed_data):
plot_data = {}
for s, info in parsed_data.items():
plot_data[s] = info["umi_counts"]
config = {'xlab': "Reads per UMI", 'ylab': "Count",
"xDecimals": False}
return {'name': 'UMI count distribution',
'anchor': 'umi-stats-counts',
'plot': linegraph.plot([plot_data], config)}