SKILL.md
OmicVerse visualization for bulk, color systems, and single-cell data
Overview
Leverage this skill when a user wants help recreating or adapting plots from the OmicVerse plotting tutorials:
- [
tvisualizebulk.ipynb](../../omicverseguide/docs/Tutorials-plotting/tvisualize_bulk.ipynb) - [
tvisualizecolorsystem.ipynb](../../omicverseguide/docs/Tutorials-plotting/tvisualize_colorsystem.ipynb) - [
tvisualizesingle.ipynb](../../omicverseguide/docs/Tutorials-plotting/tvisualize_single.ipynb)
It covers how to configure OmicVerse's plotting style, choose colors from the Forbidden City palette, and generate bulk as well as single-cell specific figures.
Instructions
- Set up the plotting environment
- Import omicverse as ov, matplotlib.pyplot as plt, and other libraries required by the user's request (pandas, seaborn, scanpy, etc.). - Call ov.ovplotset() (or ov.plot_set() depending on the installed version) to apply OmicVerse's default styling before generating figures. - Load example data via ov.read(...)/ov.pp.preprocess(...) or instruct users to supply their own AnnData/CSV files.
- Bulk RNA-seq visuals (
tvisualizebulk)
- Use ov.pl.venn(sets=..., palette=...) to display overlaps among DEG lists (no more than 4 groups). Encourage setting sets as a dictionary of set names → gene lists. - For volcano plots, load the DEG table (result = ov.read('...csv')) and call ov.pl.volcano(result, pvalname='qvalue', fcname='log2FoldChange', ...). Explain optional keyword arguments such as sigpvalue, sigfc, palette, and label formatting. - To compare group distributions with box plots, gather long-form data (e.g., from seaborn.loaddataset('tips')) and invoke ov.pl.boxplot(data, xvalue=..., y_value=..., hue=..., ax=ax, palette=...). Mention how to adjust figure size, legend placement, and significance annotations.
- Color management (
tvisualizecolorsystem)
- Introduce the color book via fb = ov.pl.ForbiddenCity() and demonstrate fb.getcolor(name='凝夜紫') for specific hues. - Show how to pull predefined palettes (ov.pl.greencolor, ov.pl.redcolor, etc.) and build dicts mapping cell types/groups to color hex codes. - For segmented gradients, combine colors and call ov.pl.getcmapseg(colors, name='custom'), then pass the colormap into Matplotlib/Scanpy plotting functions. - Highlight using these palettes in embeddings: ov.pl.embedding(adata, basis='Xumap', color='clusters', palette=color_dict, ax=ax).
- Single-cell visualizations (
tvisualizesingle)
- Remind users to preprocess AnnData if needed (adata = ov.pp.preprocess(adata, mode='shiftlog|pearson', nHVGs=2000)). - IMPORTANT - Data validation: Before plotting, always verify that required data exists: ```python # Before plotting by clustering or other categorical variable colorcol = 'leiden' # or 'clusters', 'celltype', etc. if colorcol not in adata.obs.columns: raise ValueError(f"Column '{colorcol}' not found in adata.obs. Available columns: {list(adata.obs.columns)}")
# Before plotting embeddings basis = 'Xumap' # or 'Xpca', 'Xtsne', etc. if basis not in adata.obsm.keys(): raise ValueError(f"Embedding '{basis}' not found in adata.obsm. Available embeddings: {list(adata.obsm.keys())}") `` - For palette optimization, use ov.pl.optimpalette(adata, basis='Xumap', colors='clusters') to auto-generate color schemes when categories clash. - Reproduce stacked proportions with ov.pl.cellproportion(adata, groupby='clusters', celltypeclusters='celltype', ax=ax) and transform into stacked area charts by setting kind='area'. - Showcase compound embedding utilities: - ov.pl.embeddingcelltype to place counts/proportions alongside UMAPs. - ov.pl.ConvexHull or ov.pl.contour for highlighting regions of interest. - ov.pl.embeddingadjust to reposition legends automatically. - ov.pl.embeddingdensity for density overlays, controlling smoothness with adjust. - For spatial gene density, describe the workflow: ov.pl.calculategenedensity(adata, genes=[...], basis='spatial'), then overlay with ov.pl.embedding(..., layer='genedensity', cmap='...'). - For heatmaps, prefer the Marsilea mainline family: - ov.pl.groupheatmap for grouped expression summaries. - ov.pl.featureheatmap for cell-level ordered heatmaps. - ov.pl.dynamicheatmap for pseudotime/lineage heatmaps. - ov.pl.cellcorheatmap for group similarity heatmaps. - Treat ov.pl.complexheatmap and ov.pl.markerheatmap as compatibility entry points for older workflows rather than the default extension surface. - Keep default border=False unless a user explicitly asks for framed panels; this matches current OmicVerse heatmap styling more closely. - For trajectory heatmaps, prefer real inferred pseudotime stored on the AnnData object over synthetic ordering whenever notebook or cached lineage results are available. - Cover additional charts like ov.pl.singlegroupboxplot, ov.pl.bardotplot, ov.pl.dotplot, and legacy ov.pl.markerheatmap, emphasizing input formats (long-form DataFrame vs. AnnData with .obs annotations) and optional helpers such as ov.pl.addpalue` for manual p-value annotations.
- Finishing touches and exports
- Encourage adding titles, axis labels, and fig.tightlayout() to prevent clipping. - Suggest saving figures with fig.savefig('plot.png', dpi=300, bboxinches='tight') and documenting color mappings for reproducibility. - Troubleshoot common issues: - Missing AnnData keys: Always validate adata.obs columns and adata.obsm embeddings exist before plotting - Palette names not found: Verify color dictionaries match actual category values - Matplotlib font rendering: When using Chinese characters, ensure appropriate fonts are installed - "Could not find X in adata.obs": Check that clustering or annotation has been performed before trying to visualize results. Use defensive checks to compute missing prerequisites on-the-fly.
Examples
- "Plot a three-set Venn diagram of overlapping DEG lists and reuse Forbidden City colors for consistency."
- "Load the dentate gyrus AnnData, color clusters with
fb.get_colorselections, and render an embedding with adjusted legend placement." - "Generate single-cell proportion bar/area plots plus gene-density overlays using OmicVerse helper functions."
References
- Bulk tutorial: [
tvisualizebulk.ipynb](../../omicverseguide/docs/Tutorials-plotting/tvisualize_bulk.ipynb) - Color system tutorial: [
tvisualizecolorsystem.ipynb](../../omicverseguide/docs/Tutorials-plotting/tvisualize_colorsystem.ipynb) - Single-cell tutorial: [
tvisualizesingle.ipynb](../../omicverseguide/docs/Tutorials-plotting/tvisualize_single.ipynb) - Quick reference snippets: [
reference.md](reference.md)