Plot

Counts

class moonstone.plot.counts.PlotCountsStats(dataframe, items_name='items')[source]

Several plots available to visualize simple count data.

__init__(dataframe, items_name='items')[source]

Initialize self. See help(type(self)) for accurate signature.

plot_mean_distribution(plotting_options=None, show=True, output_file=False)[source]

method to visualize the mean distribution of the number of reads by items

Parameters
  • show (Optional[bool]) – set to False if you don’t want to show the plot

  • output_file (Optional[str]) – name of the output file

  • plotting_options (Optional[dict]) –

    options of plotting that will override the default setup

    [!] Make sure the value given to an argument is of the right type

    options allowed : ‘log’: bool ; ‘colorbar’: [str, List[str]] ; ‘tickangle’: [int, float]

class moonstone.plot.counts.PlotTaxonomyCounts(taxonomy_dataframe)[source]

Plots available for taxonomy counts (multiindexed dataframe).

__init__(taxonomy_dataframe)[source]

Initialize self. See help(type(self)) for accurate signature.

compute_prevalence_series()[source]
Return type

Series

compute_relative_abundance_dataframe()[source]
Return type

DataFrame

plot_most_abundant_taxa(mode='bargraph', taxa_level='species', taxa_number=20, average_relative_abundance_threshold=None, higher_classification=True, prevalence_threshold=None, ascending=False, **kwargs)[source]

Generate a plot of most abundant taxa.

Parameters
  • mode (str) – { ‘bargraph’ (default), ‘boxplot’, ‘violin’ } Bargraph will show you the mean relative abundance of the most abundant species among all the samples. Boxplot and violin plot will show every samples’ relative abundance as a point.

  • taxa_level (str) – Taxonomy level.

  • taxa_number (int) – Number of taxa to plot.

  • average_relative_abundance_threshold (Optional[float]) – (optional) Set a threshold, if you want to show all species with an equal or greater average relative abundance.

  • higher_classification (bool) – Set to False, if you do not want OTU only defined at a higher level to appear in the top. They will still be included in the relative abundances.

  • prevalence_threshold (Optional[float]) – Prevalence threshold for a taxa to be kept in analysis.

  • ascending (bool) – If set to True, from top to bottom, from least abundant taxa of the top to most abundant taxa.

Return type

Figure

plot_most_prevalent_taxa(mode='bargraph', taxa_level='species', taxa_number=20, prevalence_threshold=None, higher_classification=True, mean_threshold=None, mean_info=False, ascending=False, **kwargs)[source]

Generate a plot of most prevalent taxa.

Parameters
  • mode (str) – { ‘bargraph’ (default), ‘boxplot’, ‘violin’ } Bargraph will show you the prevalence of the most prevalent taxa among all the samples. Boxplot and violin plot will show every samples’ relative abundance as a point, for the top most prevalent taxa.

  • taxa_level (str) – Taxonomy level.

  • taxa_number (int) – Number of taxa to plot (skipped by prevalence_threshold).

  • prevalence_threshold (Optional[float]) – (optional) Set a threshold, if you want to show all species with an equal or greater prevalence.

  • higher_classification (bool) – Set to False, if you do not want OTU only defined at a higher level to appear in the top.

  • mean_threshold (Optional[float]) – Mean threshold for a taxa to be kept in analysis.

  • mean_info (bool) – To show the taxa’s mean counts in the graph, next to the taxa’s name.

  • ascending (bool) – If set to True, from top to bottom, from least prevalent taxa of the top to most prevalent taxa.

Return type

Figure

plot_sample_composition_most_abundant_taxa(taxa_level='species', taxa_number=20, average_relative_abundance_threshold=None, higher_classification=True, prevalence_threshold=None, cluster_samples=True, samples_order=None, color_df=None, sep_series=None, sep_how=None, **kwargs)[source]

Plot taxa composition of samples for most abundant taxa.

Parameters
  • taxa_level (str) – Taxonomy level.

  • taxa_number (int) – Number of taxa to plot (skipped by average_relative_abundance_threshold).

  • average_relative_abundance_threshold (Optional[float]) – (optional) Set a threshold, if you want to show all species with an equal or greater average relative abundance.

  • higher_classification (bool) – Set to False, if you do not want OTU only defined at a higher level to appear in the top. They will still appear in “Others”.

  • prevalence_threshold (Optional[float]) – Prevalence threshold for a taxa to be kept in analysis.

  • cluster_samples (bool) – Use clustering (skipped by samples_order).

  • samples_order (Optional[List[str]]) – List of samples to force ordering for visualization.

  • color_df (Optional[DataFrame]) – Metadata to put as legend on the bottom of the graph.

  • sep_series (Optional[Series]) – Metadata used to order samples into subgroups (skipped by samples_order).

  • sep_how (Optional[str]) – { None (default), ‘color’, ‘labels’ } Graphical way of showing the separation of the different subgroups (skipped if sep_series is empty/None).

Return type

Figure

property prevalence_series
property relative_abundance_dataframe

Metadata

class moonstone.plot.metadata.PlotMetadataStats(metadata_dataframe)[source]

Several plots available to visualize metadata.

__init__(metadata_dataframe)[source]

Initialize self. See help(type(self)) for accurate signature.

plot_age(bins_size=None, plotting_options=None, show=True, output_file=False)[source]

method to visualize the age distribution of patients (whose the samples are originated from)

Parameters
  • bins_size – size of the bins of the Histogram

  • show (Optional[bool]) – set to False if you don’t want to show the plot

  • output_file (Optional[str]) – name of the output file

  • plotting_options (Optional[dict]) –

    options of plotting that will override the default setup

    [!] Make sure the value given to an argument is of the right type

    options allowed : ‘log’: bool ; ‘colorbar’: [str, List[str]] ; ‘tickangle’: [int, float]

Return type

Figure

plot_sex(sex_col='sex', plotting_options=None, show=True, output_file=False)[source]

method to visualize the sex distribution of patients (whose the samples are originated from)

Parameters
  • show (Optional[bool]) – set to False if you don’t want to show the plot

  • output_file (Optional[str]) – name of the output file

  • plotting_options (Optional[dict]) –

    options of plotting that will override the default setup

    [!] Make sure the value given to an argument is of the right type

    options allowed : ‘log’: bool ; ‘colorbar’: [str, List[str]] ; ‘tickangle’: [int, float]

plot_category_distribution(column_name, title=None, xlabel=None, reset_xnames_dic=None, plotting_options=None, show=True, output_file=False)[source]
Parameters
  • column_name – name of the column you wish to display into a barplot

  • title – title of the graph

  • xlabel – label of the x axis

  • reset_xnames_dic (Optional[dict]) –

    to rename the names of the values in the x axis.

    Example for a plot of the distribution of smoking habits : reset_xnames_dic={‘y’: ‘smoker’, ‘n’: ‘non smoker’}

  • show (Optional[bool]) – set to False if you don’t want to show the plot

  • output_file (Optional[str]) – name of the output file

  • plotting_options (Optional[dict]) –

    options of plotting that will override the default setup

    [!] Make sure the value given to an argument is of the right type

    options allowed : ‘log’: bool ; ‘colorbar’: [str, List[str]] ; ‘tickangle’: [int, float]