mmc.stacked_density_plots()

mmochi.landmarking.stacked_density_plots(adata, marker_list, batch_key=utils.BATCH_KEY, data_key=['protein', 'landmark_protein'], data_key_colors=['b', 'r'], aspect=3, height=.85, save_fig=None, subsample=1, bw_adjust=0)

Method to plot multiple density plots of positive and negative peaks for batches and [data_keys]s with properly placed labels. Method will create density plots for all items in a batch to help visualize the process of realignment (landmark registration)

Code adapted from https://python.plainenglish.io/ridge-plots-with-pythons-seaborn-4de5725881af

Parameters:
  • adata (AnnData) – AnnData containing [batch] labels in obs, [data_key] in obsm, and contains all items in [markers_list] to plot found using mmc.utils.get_data
  • marker_list (Union[DataFrame, list, tuple]) – List of markers to be plotted for each [batch], uses mmc.utils.get_data to search for marker info
  • batch_key (str (default: utils.BATCH_KEY)) – Chosen labels to compare. Each item in batch will be its own row in the stacked plot
  • data_key (List[str] (default: ['protein','landmark_protein'])) – List of labels to on which to compare [batch]es. Uses mmc.utils.get_data to find labels in data_key in [adata]
  • data_key_colors (Union[List[str], List[Tuple[float]]] (default: ['b','r'])) – Colors to use for text labels for [data_key]s
  • aspect (Union[float, int] (default: 3)) – Aspect value passed to seaborne.FacetGrid function
  • height (Union[float, int] (default: .85)) – Height of the plots. Passed to seaborne.FacetGrid and matplotlib.plt.text functions
  • save_fig (Optional[str] (default: None)) – Filepath to save figure to. If none, will not save figure
  • subsample (Union[float, int] (default: 1)) – Fraction of adata data to use for plotting. If less than 1 that fraction will be chosen randomly
  • bw_adjust (Union[float, int] (default: 0)) – Scalar to multiply bandwidth smoothing method used by seaborn.kdeplot. See seaborne.kdeplot for more details
Return type:

None. Plots labeled stacked density plots of positive and negative peaks to compare [batch]es across [data_key]s