diff --git a/README.md b/README.md index e21cf30..a10866c 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # MutMap User Guide -#### version 2.3.2 +#### version 2.3.3 ## Table of contents - [What is MutMap?](#What-is-MutMap) @@ -71,8 +71,7 @@ trimmomatic --help ## Usage -Current version can not plot too contiguous reference genome. -**We highly recommend you to run MutMap without spcifying '--species' for multiple testing correction, initially.** +If your reference genome has more than 50 contigs (or chromosomes), only significant contigs will be plotted. ``` mutmap -h @@ -80,7 +79,7 @@ mutmap -h usage: mutmap -r -c -b -n -o [-T] [-e ] -MutMap version 2.3.2 +MutMap version 2.3.3 optional arguments: -h, --help show this help message and exit @@ -229,7 +228,7 @@ usage: mutplot -v -o -n [-w ] [-s ] [-D ] [-d ] [-N ] [-m ] [-S ] [-e ] [--igv] [--indel] -MutPlot version 2.3.2 +MutPlot version 2.3.3 optional arguments: -h, --help show this help message and exit diff --git a/mutmap/__init__.py b/mutmap/__init__.py index ef6497d..ed5cc17 100644 --- a/mutmap/__init__.py +++ b/mutmap/__init__.py @@ -1 +1 @@ -__version__ = "2.3.2" +__version__ = "2.3.3" diff --git a/mutmap/plot.py b/mutmap/plot.py index ae3e98b..f4582ac 100755 --- a/mutmap/plot.py +++ b/mutmap/plot.py @@ -1,11 +1,10 @@ -import os +import sys import warnings warnings.filterwarnings("ignore") import pandas as pd import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt -from mutmap.utils import time_stamp class Plot(object): @@ -63,6 +62,22 @@ def read_files(self): return snp_index, sliding_window + def get_significant_contigs(self, N_chr, snp_index, sliding_window): + + print(('!!WARNING!! Your reference genome has too many contigs (>50). ' + 'Therefore, only significant contigs will be plotted.'), file=sys.stderr) + + significant_windows = sliding_window[abs(sliding_window['mean_p95']) <= \ + abs(sliding_window['mean_SNPindex'])] + + significant_contigs = list(significant_windows['CHROM'].drop_duplicates()) + + N_chr = len(significant_contigs) + snp_index = snp_index[snp_index['CHROM'].isin(significant_contigs)] + sliding_window = sliding_window[sliding_window['CHROM'].isin(significant_contigs)] + + return N_chr, snp_index, sliding_window + def set_plot_style(self, N_chr): if N_chr == 1: style = (1, 1) @@ -79,6 +94,12 @@ def run(self): snp_index, sliding_window = self.read_files() N_chr = len(sliding_window['CHROM'].unique()) + + if N_chr > 50: + N_chr, self.snp_index, self.sliding_window = self.get_significant_contigs(N_chr, + snp_index, + sliding_window) + N_col, N_raw = self.set_plot_style(N_chr) fig = plt.figure(figsize=(self.fig_width*N_col, self.fig_height*N_raw))