Package: mitoviz
mitovizPlot variants on the human mitochondrial genome.Free software: MIT licenseDocumentation:https://mitoviz.readthedocs.ioGitHub repo:https://github.com/robertopreste/mitovizFeaturesmitoviz is a simple python package to plot human mitochondrial variants on a graphical
representation of the human mitochondrial genome. It currently supports plotting variants
stored in VCF and tabular files, as well as from generalpandasdataframes when importing
mitoviz in Python.Variants are shown according to their heteroplasmic fraction (HF), plotting variants with
HF = 1.0 on the outer border of the mitochondrial circle, those with HF = 0.0 on the inner
border and all the others in between, according to their actual HF value.If the HF information is not available, variants will all be shown in the middle of the
mitochondrial circle.A linear representation of the mitochondrial genome can also be plotted; in this case,
variants are shown using alollipop plotstyle, with the height of the marker reflecting
their HF.Variants with no HF information will be shown as if their HF was 0.5.Usagemitoviz can be used both from the command line and as a python module.Command LineGiven a VCF file with human mitochondrial variants (sample.vcf), plotting them is fairly
simple:$mitovizsample.vcfAn image namedmitoviz.pngwill be created in the current directory; if you want to provide a
specific filename where the plot will be saved, just add the--outputoption with the desired
path:$mitovizsample.vcf--outputmy_mt_plot.pngLinear plots can be created using the--linearoption:$mitovizsample.vcf--linearPolar and linear interactive plots can also be created by adding the--interactiveoption, and
will be saved to an HTML file:$mitovizsample.vcf--interactiveIt is also possible to plot variants stored in a tabular file, such as CSV or TSV formats; mitoviz
will automatically recognise them, treating the file as comma-separated by default. If a different
separator is used (as in the case of TSV files), just specify it with the--sepoption:$mitovizsample.tsv--sep"\t"If you just need to create an empty mitochondrial plot, we’ve got you covered: use themitoviz-basecommand and provide one or more options like--linear,--interactive,--legend,--split,--output, based on your needs.Python ModuleImport mitoviz and use itsplot_vcffunction to use it in your own script:frommitovizimportplot_vcfmy_plot=plot_vcf("sample.vcf")In this case, no plot will be shown until a call toplt.show()is made. It is possible to
save the resulting plot using thesaveoption and to provide a specific file where the plot
will be saved using theoutputoption:plot_vcf("sample.vcf",save=True,output="my_mt_plot.png")By default, a polar plot is returned; linear plots are easily created using thelinearoption:plot_vcf("sample.vcf",save=True,linear=True)Interactive plots can be created with theinteractiveoption, and can be either saved to an
HTML file or inspected in a Jupyter notebook:# Show the interactive plot (works in a Jupyter notebook)plot_vcf("sample.vcf",interactive=True)# Save the interactive plot to an HTML fileplot_vcf("sample.vcf",interactive=True,save=True)A similar function to plot variants contained in a pandas DataFrame is available asplot_df.
Supposing you have a pandas DataFrame with human mitochondrial variants namedvariants_df, it
is possible to plot them as follows:frommitovizimportplot_dfplot_df(variants_df)Variants stored in tabular files can be plotted usingplot_table, which accepts the same
options available forplot_vcfandplot_df, with the addition ofsep, which is used to
specify the column separator. By default, the comma is used as column delimiter:frommitovizimportplot_table# plotting a CSV fileplot_table("sample.csv")# plotting a TSV (tab-separated) fileplot_table("sample.tsv",sep="\t")plot_tablealso accept additional keyword options, which will be passed topandas.read_tablewhen processing the given input file:plot_table("sample.tsv",sep="\t",comment="#",skiprows=0)If you just need to create an empty mitochondrial plot, theplot_basefunction allows to do so,
and accepts thelinear,interactive,legend,split,outputandsavearguments to further tweak its behaviour.Please refer to theUsagesection of the documentation for further information.InstallationPLEASE NOTE: HmtNote only supports Python >= 3.6!The preferred installation method for mitoviz is usingpip:$pipinstallmitovizPlease refer to theInstallationsection of the documentation for further information.CreditsThis package was created withCookiecutterand thecc-pypackageproject template.History0.1.0 (2019-12-27)First release.0.2.0 (2019-12-29)Add functionality to plot multiple samples.0.2.1 (2020-01-06)Add legend to plots and update colors.0.2.2 (2020-01-08)Add option to plot variant labels.0.2.3 (2020-01-11)Make legend plotting optional.0.3.0 (2020-01-15)Addplot_dffunction to plot variants from a pandas DataFrame.0.4.0 (2020-01-26)Addplot_tablefunction to plot variants from tabular files;add CLI functionality to plot variants from tabular files;refactor code.0.4.1 (2020-02-13)Refactor to use abstract classes;Rename internal classes to _PolarLocus and _PolarVariant.0.4.2 (2020-02-14)Fix bug with non coding loci not being shown in plots.0.5.0 (2020-02-19)Addsplitoption to plot split strands on polar plots.0.6.0 (2020-02-29)_PolarVariantis deprecated and replaced by_Variant;Addlinearoption to create linear plots.0.6.1 (2020-03-02)Refactor and clean code;Add CI module for internal management.0.6.2 (2020-03-03)Fix borders on linear plots.0.6.3 (2020-03-04)Fix stemlines on split linear plots.0.6.4 (2020-03-10)Fix loci label positions on polar plots.0.7.0 (2020-03-15)Add--interactiveoption to create interactive plots using plot.ly;Implement interactive basic polar plots;Implement interactive split polar plots.0.7.1 (2020-03-28)Implement interactive basic linear plots;Implement interactive split linear plots.0.8.0 (2020-04-05)Addmitoviz-basecommand to create base mitochondrial plots.0.8.1 (2020-04-12)Move test images to separate subrepo.0.8.2 (2020-04-20)Add--labels-hf(labels-hf=Truein Python) options to include the HF value
in plot labels.0.9.0 (2020-06-11)Refactor code to create plotting classes.