[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71JWH2Q9MTSD2R46R9EG6CB":3,"skill-same:01M71JWH2Q9MTSD2R46R9EG6CB":85},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":34,"linkOnly":35,"markdownContent":36,"markdownBody":37,"frontMatter":38,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":48,"ownerDescription":49,"updatedAt":50,"install":51,"resources":64},"01M71JWH2Q9MTSD2R46R9EG6CB","pydeseq2",null,"Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano\u002FMA plots, for RNA-seq analysis.","iDorgham\u002FWorkspace-Factory","iDorgham","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F136521493?v=4","01M6CNGBDAHE4ARW3YJEF4X2FD","Dorgham","01M71E8H3CXZ7DJX59MTM9JEB2",1,"MIT","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpydeseq2\u002FSKILL.md",[],[5,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],"bulk","fdr","expression","analysis","RNA","de","DESeq2","gene expression","volcano","gene","seq","for","python","tests","rna-seq","2026-11-10 10:12:30",false,"---\nname: pydeseq2\ndescription: Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano\u002FMA plots, for RNA-seq analysis.\nlicense: MIT license\nmetadata:\n    skill-author: K-Dense Inc.\n---\n\n# PyDESeq2\n\n## Overview\n\nPyDESeq2 is a Python implementation of DESeq2 for differential expression analysis with bulk RNA-seq data. Design and execute complete workflows from data loading through result interpretation, including single-factor and multi-factor designs, Wald tests with multiple testing correction, optional apeGLM shrinkage, and integration with pandas and AnnData.\n\n## When to Use This Skill\n\nThis skill should be used when:\n- Analyzing bulk RNA-seq count data for differential expression\n- Comparing gene expression between experimental conditions (e.g., treated vs control)\n- Performing multi-factor designs accounting for batch effects or covariates\n- Converting R-based DESeq2 workflows to Python\n- Integrating differential expression analysis into Python-based pipelines\n- Users mention \"DESeq2\", \"differential expression\", \"RNA-seq analysis\", or \"PyDESeq2\"\n\n## Quick Start Workflow\n\nFor users who want to perform a standard differential expression analysis:\n\n```python\nimport pandas as pd\nfrom pydeseq2.dds import DeseqDataSet\nfrom pydeseq2.ds import DeseqStats\n\n# 1. Load data\ncounts_df = pd.read_csv(\"counts.csv\", index_col=0).T  # Transpose to samples × genes\nmetadata = pd.read_csv(\"metadata.csv\", index_col=0)\n\n# 2. Filter low-count genes\ngenes_to_keep = counts_df.columns[counts_df.sum(axis=0) >= 10]\ncounts_df = counts_df[genes_to_keep]\n\n# 3. Initialize and fit DESeq2\ndds = DeseqDataSet(\n    counts=counts_df,\n    metadata=metadata,\n    design=\"~condition\",\n    refit_cooks=True\n)\ndds.deseq2()\n\n# 4. Perform statistical testing\nds = DeseqStats(dds, contrast=[\"condition\", \"treated\", \"control\"])\nds.summary()\n\n# 5. Access results\nresults = ds.results_df\nsignificant = results[results.padj \u003C 0.05]\nprint(f\"Found {len(significant)} significant genes\")\n```\n\n## Core Workflow Steps\n\n### Step 1: Data Preparation\n\n**Input requirements:**\n- **Count matrix:** Samples × genes DataFrame with non-negative integer read counts\n- **Metadata:** Samples × variables DataFrame with experimental factors\n\n**Common data loading patterns:**\n\n```python\n# From CSV (typical format: genes × samples, needs transpose)\ncounts_df = pd.read_csv(\"counts.csv\", index_col=0).T\nmetadata = pd.read_csv(\"metadata.csv\", index_col=0)\n\n# From TSV\ncounts_df = pd.read_csv(\"counts.tsv\", sep=\"\\t\", index_col=0).T\n\n# From AnnData\nimport anndata as ad\nadata = ad.read_h5ad(\"data.h5ad\")\ncounts_df = pd.DataFrame(adata.X, index=adata.obs_names, columns=adata.var_names)\nmetadata = adata.obs\n```\n\n**Data filtering:**\n\n```python\n# Remove low-count genes\ngenes_to_keep = counts_df.columns[counts_df.sum(axis=0) >= 10]\ncounts_df = counts_df[genes_to_keep]\n\n# Remove samples with missing metadata\nsamples_to_keep = ~metadata.condition.isna()\ncounts_df = counts_df.loc[samples_to_keep]\nmetadata = metadata.loc[samples_to_keep]\n```\n\n### Step 2: Design Specification\n\nThe design formula specifies how gene expression is modeled.\n\n**Single-factor designs:**\n```python\ndesign = \"~condition\"  # Simple two-group comparison\n```\n\n**Multi-factor designs:**\n```python\ndesign = \"~batch + condition\"  # Control for batch effects\ndesign = \"~age + condition\"     # Include continuous covariate\ndesign = \"~group + condition + group:condition\"  # Interaction effects\n```\n\n**Design formula guidelines:**\n- Use Wilkinson formula notation (R-style)\n- Put adjustment variables (e.g., batch) before the main variable of interest\n- Ensure variables exist as columns in the metadata DataFrame\n- Use appropriate data types (categorical for discrete variables)\n\n### Step 3: DESeq2 Fitting\n\nInitialize the DeseqDataSet and run the complete pipeline:\n\n```python\nfrom pydeseq2.dds import DeseqDataSet\n\ndds = DeseqDataSet(\n    counts=counts_df,\n    metadata=metadata,\n    design=\"~condition\",\n    refit_cooks=True,  # Refit after removing outliers\n    n_cpus=1           # Parallel processing (adjust as needed)\n)\n\n# Run the complete DESeq2 pipeline\ndds.deseq2()\n```\n\n**What `deseq2()` does:**\n1. Computes size factors (normalization)\n2. Fits genewise dispersions\n3. Fits dispersion trend curve\n4. Computes dispersion priors\n5. Fits MAP dispersions (shrinkage)\n6. Fits log fold changes\n7. Calculates Cook's distances (outlier detection)\n8. Refits if outliers detected (optional)\n\n### Step 4: Statistical Testing\n\nPerform Wald tests to identify differentially expressed genes:\n\n```python\nfrom pydeseq2.ds import DeseqStats\n\nds = DeseqStats(\n    dds,\n    contrast=[\"condition\", \"treated\", \"control\"],  # Test treated vs control\n    alpha=0.05,                # Significance threshold\n    cooks_filter=True,         # Filter outliers\n    independent_filter=True    # Filter low-power tests\n)\n\nds.summary()\n```\n\n**Contrast specification:**\n- Format: `[variable, test_level, reference_level]`\n- Example: `[\"condition\", \"treated\", \"control\"]` tests treated vs control\n- If `None`, uses the last coefficient in the design\n\n**Result DataFrame columns:**\n- `baseMean`: Mean normalized count across samples\n- `log2FoldChange`: Log2 fold change between conditions\n- `lfcSE`: Standard error of LFC\n- `stat`: Wald test statistic\n- `pvalue`: Raw p-value\n- `padj`: Adjusted p-value (FDR-corrected via Benjamini-Hochberg)\n\n### Step 5: Optional LFC Shrinkage\n\nApply shrinkage to reduce noise in fold change estimates:\n\n```python\nds.lfc_shrink()  # Applies apeGLM shrinkage\n```\n\n**When to use LFC shrinkage:**\n- For visualization (volcano plots, heatmaps)\n- For ranking genes by effect size\n- When prioritizing genes for follow-up experiments\n\n**Important:** Shrinkage affects only the log2FoldChange values, not the statistical test results (p-values remain unchanged). Use shrunk values for visualization but report unshrunken p-values for significance.\n\n### Step 6: Result Export\n\nSave results and intermediate objects:\n\n```python\nimport pickle\n\n# Export results as CSV\nds.results_df.to_csv(\"deseq2_results.csv\")\n\n# Save significant genes only\nsignificant = ds.results_df[ds.results_df.padj \u003C 0.05]\nsignificant.to_csv(\"significant_genes.csv\")\n\n# Save DeseqDataSet for later use\nwith open(\"dds_result.pkl\", \"wb\") as f:\n    pickle.dump(dds.to_picklable_anndata(), f)\n```\n\n## Common Analysis Patterns\n\n### Two-Group Comparison\n\nStandard case-control comparison:\n\n```python\ndds = DeseqDataSet(counts=counts_df, metadata=metadata, design=\"~condition\")\ndds.deseq2()\n\nds = DeseqStats(dds, contrast=[\"condition\", \"treated\", \"control\"])\nds.summary()\n\nresults = ds.results_df\nsignificant = results[results.padj \u003C 0.05]\n```\n\n### Multiple Comparisons\n\nTesting multiple treatment groups against control:\n\n```python\ndds = DeseqDataSet(counts=counts_df, metadata=metadata, design=\"~condition\")\ndds.deseq2()\n\ntreatments = [\"treatment_A\", \"treatment_B\", \"treatment_C\"]\nall_results = {}\n\nfor treatment in treatments:\n    ds = DeseqStats(dds, contrast=[\"condition\", treatment, \"control\"])\n    ds.summary()\n    all_results[treatment] = ds.results_df\n\n    sig_count = len(ds.results_df[ds.results_df.padj \u003C 0.05])\n    print(f\"{treatment}: {sig_count} significant genes\")\n```\n\n### Accounting for Batch Effects\n\nControl for technical variation:\n\n```python\n# Include batch in design\ndds = DeseqDataSet(counts=counts_df, metadata=metadata, design=\"~batch + condition\")\ndds.deseq2()\n\n# Test condition while controlling for batch\nds = DeseqStats(dds, contrast=[\"condition\", \"treated\", \"control\"])\nds.summary()\n```\n\n### Continuous Covariates\n\nInclude continuous variables like age or dosage:\n\n```python\n# Ensure continuous variable is numeric\nmetadata[\"age\"] = pd.to_numeric(metadata[\"age\"])\n\ndds = DeseqDataSet(counts=counts_df, metadata=metadata, design=\"~age + condition\")\ndds.deseq2()\n\nds = DeseqStats(dds, contrast=[\"condition\", \"treated\", \"control\"])\nds.summary()\n```\n\n## Using the Analysis Script\n\nThis skill includes a complete command-line script for standard analyses:\n\n```bash\n# Basic usage\npython scripts\u002Frun_deseq2_analysis.py \\\n  --counts counts.csv \\\n  --metadata metadata.csv \\\n  --design \"~condition\" \\\n  --contrast condition treated control \\\n  --output results\u002F\n\n# With additional options\npython scripts\u002Frun_deseq2_analysis.py \\\n  --counts counts.csv \\\n  --metadata metadata.csv \\\n  --design \"~batch + condition\" \\\n  --contrast condition treated control \\\n  --output results\u002F \\\n  --min-counts 10 \\\n  --alpha 0.05 \\\n  --n-cpus 4 \\\n  --plots\n```\n\n**Script features:**\n- Automatic data loading and validation\n- Gene and sample filtering\n- Complete DESeq2 pipeline execution\n- Statistical testing with customizable parameters\n- Result export (CSV, pickle)\n- Optional visualization (volcano and MA plots)\n\nRefer users to `scripts\u002Frun_deseq2_analysis.py` when they need a standalone analysis tool or want to batch process multiple datasets.\n\n## Result Interpretation\n\n### Identifying Significant Genes\n\n```python\n# Filter by adjusted p-value\nsignificant = ds.results_df[ds.results_df.padj \u003C 0.05]\n\n# Filter by both significance and effect size\nsig_and_large = ds.results_df[\n    (ds.results_df.padj \u003C 0.05) &\n    (abs(ds.results_df.log2FoldChange) > 1)\n]\n\n# Separate up- and down-regulated\nupregulated = significant[significant.log2FoldChange > 0]\ndownregulated = significant[significant.log2FoldChange \u003C 0]\n\nprint(f\"Upregulated: {len(upregulated)}\")\nprint(f\"Downregulated: {len(downregulated)}\")\n```\n\n### Ranking and Sorting\n\n```python\n# Sort by adjusted p-value\ntop_by_padj = ds.results_df.sort_values(\"padj\").head(20)\n\n# Sort by absolute fold change (use shrunk values)\nds.lfc_shrink()\nds.results_df[\"abs_lfc\"] = abs(ds.results_df.log2FoldChange)\ntop_by_lfc = ds.results_df.sort_values(\"abs_lfc\", ascending=False).head(20)\n\n# Sort by a combined metric\nds.results_df[\"score\"] = -np.log10(ds.results_df.padj) * abs(ds.results_df.log2FoldChange)\ntop_combined = ds.results_df.sort_values(\"score\", ascending=False).head(20)\n```\n\n### Quality Metrics\n\n```python\n# Check normalization (size factors should be close to 1)\nprint(\"Size factors:\", dds.obsm[\"size_factors\"])\n\n# Examine dispersion estimates\nimport matplotlib.pyplot as plt\nplt.hist(dds.varm[\"dispersions\"], bins=50)\nplt.xlabel(\"Dispersion\")\nplt.ylabel(\"Frequency\")\nplt.title(\"Dispersion Distribution\")\nplt.show()\n\n# Check p-value distribution (should be mostly flat with peak near 0)\nplt.hist(ds.results_df.pvalue.dropna(), bins=50)\nplt.xlabel(\"P-value\")\nplt.ylabel(\"Frequency\")\nplt.title(\"P-value Distribution\")\nplt.show()\n```\n\n## Visualization Guidelines\n\n### Volcano Plot\n\nVisualize significance vs effect size:\n\n```python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nresults = ds.results_df.copy()\nresults[\"-log10(padj)\"] = -np.log10(results.padj)\n\nplt.figure(figsize=(10, 6))\nsignificant = results.padj \u003C 0.05\n\nplt.scatter(\n    results.loc[~significant, \"log2FoldChange\"],\n    results.loc[~significant, \"-log10(padj)\"],\n    alpha=0.3, s=10, c='gray', label='Not significant'\n)\nplt.scatter(\n    results.loc[significant, \"log2FoldChange\"],\n    results.loc[significant, \"-log10(padj)\"],\n    alpha=0.6, s=10, c='red', label='padj \u003C 0.05'\n)\n\nplt.axhline(-np.log10(0.05), color='blue', linestyle='--', alpha=0.5)\nplt.xlabel(\"Log2 Fold Change\")\nplt.ylabel(\"-Log10(Adjusted P-value)\")\nplt.title(\"Volcano Plot\")\nplt.legend()\nplt.savefig(\"volcano_plot.png\", dpi=300)\n```\n\n### MA Plot\n\nShow fold change vs mean expression:\n\n```python\nplt.figure(figsize=(10, 6))\n\nplt.scatter(\n    np.log10(results.loc[~significant, \"baseMean\"] + 1),\n    results.loc[~significant, \"log2FoldChange\"],\n    alpha=0.3, s=10, c='gray'\n)\nplt.scatter(\n    np.log10(results.loc[significant, \"baseMean\"] + 1),\n    results.loc[significant, \"log2FoldChange\"],\n    alpha=0.6, s=10, c='red'\n)\n\nplt.axhline(0, color='blue', linestyle='--', alpha=0.5)\nplt.xlabel(\"Log10(Base Mean + 1)\")\nplt.ylabel(\"Log2 Fold Change\")\nplt.title(\"MA Plot\")\nplt.savefig(\"ma_plot.png\", dpi=300)\n```\n\n## Troubleshooting Common Issues\n\n### Data Format Problems\n\n**Issue:** \"Index mismatch between counts and metadata\"\n\n**Solution:** Ensure sample names match exactly\n```python\nprint(\"Counts samples:\", counts_df.index.tolist())\nprint(\"Metadata samples:\", metadata.index.tolist())\n\n# Take intersection if needed\ncommon = counts_df.index.intersection(metadata.index)\ncounts_df = counts_df.loc[common]\nmetadata = metadata.loc[common]\n```\n\n**Issue:** \"All genes have zero counts\"\n\n**Solution:** Check if data needs transposition\n```python\nprint(f\"Counts shape: {counts_df.shape}\")\n# If genes > samples, transpose is needed\nif counts_df.shape[1] \u003C counts_df.shape[0]:\n    counts_df = counts_df.T\n```\n\n### Design Matrix Issues\n\n**Issue:** \"Design matrix is not full rank\"\n\n**Cause:** Confounded variables (e.g., all treated samples in one batch)\n\n**Solution:** Remove confounded variable or add interaction term\n```python\n# Check confounding\nprint(pd.crosstab(metadata.condition, metadata.batch))\n\n# Either simplify design or add interaction\ndesign = \"~condition\"  # Remove batch\n# OR\ndesign = \"~condition + batch + condition:batch\"  # Model interaction\n```\n\n### No Significant Genes\n\n**Diagnostics:**\n```python\n# Check dispersion distribution\nplt.hist(dds.varm[\"dispersions\"], bins=50)\nplt.show()\n\n# Check size factors\nprint(dds.obsm[\"size_factors\"])\n\n# Look at top genes by raw p-value\nprint(ds.results_df.nsmallest(20, \"pvalue\"))\n```\n\n**Possible causes:**\n- Small effect sizes\n- High biological variability\n- Insufficient sample size\n- Technical issues (batch effects, outliers)\n\n## Reference Documentation\n\nFor comprehensive details beyond this workflow-oriented guide:\n\n- **API Reference** (`references\u002Fapi_reference.md`): Complete documentation of PyDESeq2 classes, methods, and data structures. Use when needing detailed parameter information or understanding object attributes.\n\n- **Workflow Guide** (`references\u002Fworkflow_guide.md`): In-depth guide covering complete analysis workflows, data loading patterns, multi-factor designs, troubleshooting, and best practices. Use when handling complex experimental designs or encountering issues.\n\nLoad these references into context when users need:\n- Detailed API documentation: `Read references\u002Fapi_reference.md`\n- Comprehensive workflow examples: `Read references\u002Fworkflow_guide.md`\n- Troubleshooting guidance: `Read references\u002Fworkflow_guide.md` (see Troubleshooting section)\n\n## Key Reminders\n\n1. **Data orientation matters:** Count matrices typically load as genes × samples but need to be samples × genes. Always transpose with `.T` if needed.\n\n2. **Sample filtering:** Remove samples with missing metadata before analysis to avoid errors.\n\n3. **Gene filtering:** Filter low-count genes (e.g., \u003C 10 total reads) to improve power and reduce computational time.\n\n4. **Design formula order:** Put adjustment variables before the variable of interest (e.g., `\"~batch + condition\"` not `\"~condition + batch\"`).\n\n5. **LFC shrinkage timing:** Apply shrinkage after statistical testing and only for visualization\u002Franking purposes. P-values remain based on unshrunken estimates.\n\n6. **Result interpretation:** Use `padj \u003C 0.05` for significance, not raw p-values. The Benjamini-Hochberg procedure controls false discovery rate.\n\n7. **Contrast specification:** The format is `[variable, test_level, reference_level]` where test_level is compared against reference_level.\n\n8. **Save intermediate objects:** Use pickle to save DeseqDataSet objects for later use or additional analyses without re-running the expensive fitting step.\n\n## Installation and Requirements\n\n```bash\nuv pip install pydeseq2\n```\n\n**System requirements:**\n- Python 3.10-3.11\n- pandas 1.4.3+\n- numpy 1.23.0+\n- scipy 1.11.0+\n- scikit-learn 1.1.1+\n- anndata 0.8.0+\n\n**Optional for visualization:**\n- matplotlib\n- seaborn\n\n## Additional Resources\n\n- **Official Documentation:** https:\u002F\u002Fpydeseq2.readthedocs.io\n- **GitHub Repository:** https:\u002F\u002Fgithub.com\u002Fowkin\u002FPyDESeq2\n- **Publication:** Muzellec et al. (2023) Bioinformatics, DOI: 10.1093\u002Fbioinformatics\u002Fbtad547\n- **Original DESeq2 (R):** Love et al. (2014) Genome Biology, DOI: 10.1186\u002Fs13059-014-0550-8\n\n","# PyDESeq2\n\n## Overview\n\nPyDESeq2 is a Python implementation of DESeq2 for differential expression analysis with bulk RNA-seq data. Design and execute complete workflows from data loading through result interpretation, including single-factor and multi-factor designs, Wald tests with multiple testing correction, optional apeGLM shrinkage, and integration with pandas and AnnData.\n\n## When to Use This Skill\n\nThis skill should be used when:\n- Analyzing bulk RNA-seq count data for differential expression\n- Comparing gene expression between experimental conditions (e.g., treated vs control)\n- Performing multi-factor designs accounting for batch effects or covariates\n- Converting R-based DESeq2 workflows to Python\n- Integrating differential expression analysis into Python-based pipelines\n- Users mention \"DESeq2\", \"differential expression\", \"RNA-seq analysis\", or \"PyDESeq2\"\n\n## Quick Start Workflow\n\nFor users who want to perform a standard differential expression analysis:\n\n```python\nimport pandas as pd\nfrom pydeseq2.dds import DeseqDataSet\nfrom pydeseq2.ds import DeseqStats\n\n# 1. Load data\ncounts_df = pd.read_csv(\"counts.csv\", index_col=0).T  # Transpose to samples × genes\nmetadata = pd.read_csv(\"metadata.csv\", index_col=0)\n\n# 2. Filter low-count genes\ngenes_to_keep = counts_df.columns[counts_df.sum(axis=0) >= 10]\ncounts_df = counts_df[genes_to_keep]\n\n# 3. Initialize and fit DESeq2\ndds = DeseqDataSet(\n    counts=counts_df,\n    metadata=metadata,\n    design=\"~condition\",\n    refit_cooks=True\n)\ndds.deseq2()\n\n# 4. Perform statistical testing\nds = DeseqStats(dds, contrast=[\"condition\", \"treated\", \"control\"])\nds.summary()\n\n# 5. Access results\nresults = ds.results_df\nsignificant = results[results.padj \u003C 0.05]\nprint(f\"Found {len(significant)} significant genes\")\n```\n\n## Core Workflow Steps\n\n### Step 1: Data Preparation\n\n**Input requirements:**\n- **Count matrix:** Samples × genes DataFrame with non-negative integer read counts\n- **Metadata:** Samples × variables DataFrame with experimental factors\n\n**Common data loading patterns:**\n\n```python\n# From CSV (typical format: genes × samples, needs transpose)\ncounts_df = pd.read_csv(\"counts.csv\", index_col=0).T\nmetadata = pd.read_csv(\"metadata.csv\", index_col=0)\n\n# From TSV\ncounts_df = pd.read_csv(\"counts.tsv\", sep=\"\\t\", index_col=0).T\n\n# From AnnData\nimport anndata as ad\nadata = ad.read_h5ad(\"data.h5ad\")\ncounts_df = pd.DataFrame(adata.X, index=adata.obs_names, columns=adata.var_names)\nmetadata = adata.obs\n```\n\n**Data filtering:**\n\n```python\n# Remove low-count genes\ngenes_to_keep = counts_df.columns[counts_df.sum(axis=0) >= 10]\ncounts_df = counts_df[genes_to_keep]\n\n# Remove samples with missing metadata\nsamples_to_keep = ~metadata.condition.isna()\ncounts_df = counts_df.loc[samples_to_keep]\nmetadata = metadata.loc[samples_to_keep]\n```\n\n### Step 2: Design Specification\n\nThe design formula specifies how gene expression is modeled.\n\n**Single-factor designs:**\n```python\ndesign = \"~condition\"  # Simple two-group comparison\n```\n\n**Multi-factor designs:**\n```python\ndesign = \"~batch + condition\"  # Control for batch effects\ndesign = \"~age + condition\"     # Include continuous covariate\ndesign = \"~group + condition + group:condition\"  # Interaction effects\n```\n\n**Design formula guidelines:**\n- Use Wilkinson formula notation (R-style)\n- Put adjustment variables (e.g., batch) before the main variable of interest\n- Ensure variables exist as columns in the metadata DataFrame\n- Use appropriate data types (categorical for discrete variables)\n\n### Step 3: DESeq2 Fitting\n\nInitialize the DeseqDataSet and run the complete pipeline:\n\n```python\nfrom pydeseq2.dds import DeseqDataSet\n\ndds = DeseqDataSet(\n    counts=counts_df,\n    metadata=metadata,\n    design=\"~condition\",\n    refit_cooks=True,  # Refit after removing outliers\n    n_cpus=1           # Parallel processing (adjust as needed)\n)\n\n# Run the complete DESeq2 pipeline\ndds.deseq2()\n```\n\n**What `deseq2()` does:**\n1. Computes size factors (normalization)\n2. Fits genewise dispersions\n3. Fits dispersion trend curve\n4. Computes dispersion priors\n5. Fits MAP dispersions (shrinkage)\n6. Fits log fold changes\n7. Calculates Cook's distances (outlier detection)\n8. Refits if outliers detected (optional)\n\n### Step 4: Statistical Testing\n\nPerform Wald tests to identify differentially expressed genes:\n\n```python\nfrom pydeseq2.ds import DeseqStats\n\nds = DeseqStats(\n    dds,\n    contrast=[\"condition\", \"treated\", \"control\"],  # Test treated vs control\n    alpha=0.05,                # Significance threshold\n    cooks_filter=True,         # Filter outliers\n    independent_filter=True    # Filter low-power tests\n)\n\nds.summary()\n```\n\n**Contrast specification:**\n- Format: `[variable, test_level, reference_level]`\n- Example: `[\"condition\", \"treated\", \"control\"]` tests treated vs control\n- If `None`, uses the last coefficient in the design\n\n**Result DataFrame columns:**\n- `baseMean`: Mean normalized count across samples\n- `log2FoldChange`: Log2 fold change between conditions\n- `lfcSE`: Standard error of LFC\n- `stat`: Wald test statistic\n- `pvalue`: Raw p-value\n- `padj`: Adjusted p-value (FDR-corrected via Benjamini-Hochberg)\n\n### Step 5: Optional LFC Shrinkage\n\nApply shrinkage to reduce noise in fold change estimates:\n\n```python\nds.lfc_shrink()  # Applies apeGLM shrinkage\n```\n\n**When to use LFC shrinkage:**\n- For visualization (volcano plots, heatmaps)\n- For ranking genes by effect size\n- When prioritizing genes for follow-up experiments\n\n**Important:** Shrinkage affects only the log2FoldChange values, not the statistical test results (p-values remain unchanged). Use shrunk values for visualization but report unshrunken p-values for significance.\n\n### Step 6: Result Export\n\nSave results and intermediate objects:\n\n```python\nimport pickle\n\n# Export results as CSV\nds.results_df.to_csv(\"deseq2_results.csv\")\n\n# Save significant genes only\nsignificant = ds.results_df[ds.results_df.padj \u003C 0.05]\nsignificant.to_csv(\"significant_genes.csv\")\n\n# Save DeseqDataSet for later use\nwith open(\"dds_result.pkl\", \"wb\") as f:\n    pickle.dump(dds.to_picklable_anndata(), f)\n```\n\n## Common Analysis Patterns\n\n### Two-Group Comparison\n\nStandard case-control comparison:\n\n```python\ndds = DeseqDataSet(counts=counts_df, metadata=metadata, design=\"~condition\")\ndds.deseq2()\n\nds = DeseqStats(dds, contrast=[\"condition\", \"treated\", \"control\"])\nds.summary()\n\nresults = ds.results_df\nsignificant = results[results.padj \u003C 0.05]\n```\n\n### Multiple Comparisons\n\nTesting multiple treatment groups against control:\n\n```python\ndds = DeseqDataSet(counts=counts_df, metadata=metadata, design=\"~condition\")\ndds.deseq2()\n\ntreatments = [\"treatment_A\", \"treatment_B\", \"treatment_C\"]\nall_results = {}\n\nfor treatment in treatments:\n    ds = DeseqStats(dds, contrast=[\"condition\", treatment, \"control\"])\n    ds.summary()\n    all_results[treatment] = ds.results_df\n\n    sig_count = len(ds.results_df[ds.results_df.padj \u003C 0.05])\n    print(f\"{treatment}: {sig_count} significant genes\")\n```\n\n### Accounting for Batch Effects\n\nControl for technical variation:\n\n```python\n# Include batch in design\ndds = DeseqDataSet(counts=counts_df, metadata=metadata, design=\"~batch + condition\")\ndds.deseq2()\n\n# Test condition while controlling for batch\nds = DeseqStats(dds, contrast=[\"condition\", \"treated\", \"control\"])\nds.summary()\n```\n\n### Continuous Covariates\n\nInclude continuous variables like age or dosage:\n\n```python\n# Ensure continuous variable is numeric\nmetadata[\"age\"] = pd.to_numeric(metadata[\"age\"])\n\ndds = DeseqDataSet(counts=counts_df, metadata=metadata, design=\"~age + condition\")\ndds.deseq2()\n\nds = DeseqStats(dds, contrast=[\"condition\", \"treated\", \"control\"])\nds.summary()\n```\n\n## Using the Analysis Script\n\nThis skill includes a complete command-line script for standard analyses:\n\n```bash\n# Basic usage\npython scripts\u002Frun_deseq2_analysis.py \\\n  --counts counts.csv \\\n  --metadata metadata.csv \\\n  --design \"~condition\" \\\n  --contrast condition treated control \\\n  --output results\u002F\n\n# With additional options\npython scripts\u002Frun_deseq2_analysis.py \\\n  --counts counts.csv \\\n  --metadata metadata.csv \\\n  --design \"~batch + condition\" \\\n  --contrast condition treated control \\\n  --output results\u002F \\\n  --min-counts 10 \\\n  --alpha 0.05 \\\n  --n-cpus 4 \\\n  --plots\n```\n\n**Script features:**\n- Automatic data loading and validation\n- Gene and sample filtering\n- Complete DESeq2 pipeline execution\n- Statistical testing with customizable parameters\n- Result export (CSV, pickle)\n- Optional visualization (volcano and MA plots)\n\nRefer users to `scripts\u002Frun_deseq2_analysis.py` when they need a standalone analysis tool or want to batch process multiple datasets.\n\n## Result Interpretation\n\n### Identifying Significant Genes\n\n```python\n# Filter by adjusted p-value\nsignificant = ds.results_df[ds.results_df.padj \u003C 0.05]\n\n# Filter by both significance and effect size\nsig_and_large = ds.results_df[\n    (ds.results_df.padj \u003C 0.05) &\n    (abs(ds.results_df.log2FoldChange) > 1)\n]\n\n# Separate up- and down-regulated\nupregulated = significant[significant.log2FoldChange > 0]\ndownregulated = significant[significant.log2FoldChange \u003C 0]\n\nprint(f\"Upregulated: {len(upregulated)}\")\nprint(f\"Downregulated: {len(downregulated)}\")\n```\n\n### Ranking and Sorting\n\n```python\n# Sort by adjusted p-value\ntop_by_padj = ds.results_df.sort_values(\"padj\").head(20)\n\n# Sort by absolute fold change (use shrunk values)\nds.lfc_shrink()\nds.results_df[\"abs_lfc\"] = abs(ds.results_df.log2FoldChange)\ntop_by_lfc = ds.results_df.sort_values(\"abs_lfc\", ascending=False).head(20)\n\n# Sort by a combined metric\nds.results_df[\"score\"] = -np.log10(ds.results_df.padj) * abs(ds.results_df.log2FoldChange)\ntop_combined = ds.results_df.sort_values(\"score\", ascending=False).head(20)\n```\n\n### Quality Metrics\n\n```python\n# Check normalization (size factors should be close to 1)\nprint(\"Size factors:\", dds.obsm[\"size_factors\"])\n\n# Examine dispersion estimates\nimport matplotlib.pyplot as plt\nplt.hist(dds.varm[\"dispersions\"], bins=50)\nplt.xlabel(\"Dispersion\")\nplt.ylabel(\"Frequency\")\nplt.title(\"Dispersion Distribution\")\nplt.show()\n\n# Check p-value distribution (should be mostly flat with peak near 0)\nplt.hist(ds.results_df.pvalue.dropna(), bins=50)\nplt.xlabel(\"P-value\")\nplt.ylabel(\"Frequency\")\nplt.title(\"P-value Distribution\")\nplt.show()\n```\n\n## Visualization Guidelines\n\n### Volcano Plot\n\nVisualize significance vs effect size:\n\n```python\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nresults = ds.results_df.copy()\nresults[\"-log10(padj)\"] = -np.log10(results.padj)\n\nplt.figure(figsize=(10, 6))\nsignificant = results.padj \u003C 0.05\n\nplt.scatter(\n    results.loc[~significant, \"log2FoldChange\"],\n    results.loc[~significant, \"-log10(padj)\"],\n    alpha=0.3, s=10, c='gray', label='Not significant'\n)\nplt.scatter(\n    results.loc[significant, \"log2FoldChange\"],\n    results.loc[significant, \"-log10(padj)\"],\n    alpha=0.6, s=10, c='red', label='padj \u003C 0.05'\n)\n\nplt.axhline(-np.log10(0.05), color='blue', linestyle='--', alpha=0.5)\nplt.xlabel(\"Log2 Fold Change\")\nplt.ylabel(\"-Log10(Adjusted P-value)\")\nplt.title(\"Volcano Plot\")\nplt.legend()\nplt.savefig(\"volcano_plot.png\", dpi=300)\n```\n\n### MA Plot\n\nShow fold change vs mean expression:\n\n```python\nplt.figure(figsize=(10, 6))\n\nplt.scatter(\n    np.log10(results.loc[~significant, \"baseMean\"] + 1),\n    results.loc[~significant, \"log2FoldChange\"],\n    alpha=0.3, s=10, c='gray'\n)\nplt.scatter(\n    np.log10(results.loc[significant, \"baseMean\"] + 1),\n    results.loc[significant, \"log2FoldChange\"],\n    alpha=0.6, s=10, c='red'\n)\n\nplt.axhline(0, color='blue', linestyle='--', alpha=0.5)\nplt.xlabel(\"Log10(Base Mean + 1)\")\nplt.ylabel(\"Log2 Fold Change\")\nplt.title(\"MA Plot\")\nplt.savefig(\"ma_plot.png\", dpi=300)\n```\n\n## Troubleshooting Common Issues\n\n### Data Format Problems\n\n**Issue:** \"Index mismatch between counts and metadata\"\n\n**Solution:** Ensure sample names match exactly\n```python\nprint(\"Counts samples:\", counts_df.index.tolist())\nprint(\"Metadata samples:\", metadata.index.tolist())\n\n# Take intersection if needed\ncommon = counts_df.index.intersection(metadata.index)\ncounts_df = counts_df.loc[common]\nmetadata = metadata.loc[common]\n```\n\n**Issue:** \"All genes have zero counts\"\n\n**Solution:** Check if data needs transposition\n```python\nprint(f\"Counts shape: {counts_df.shape}\")\n# If genes > samples, transpose is needed\nif counts_df.shape[1] \u003C counts_df.shape[0]:\n    counts_df = counts_df.T\n```\n\n### Design Matrix Issues\n\n**Issue:** \"Design matrix is not full rank\"\n\n**Cause:** Confounded variables (e.g., all treated samples in one batch)\n\n**Solution:** Remove confounded variable or add interaction term\n```python\n# Check confounding\nprint(pd.crosstab(metadata.condition, metadata.batch))\n\n# Either simplify design or add interaction\ndesign = \"~condition\"  # Remove batch\n# OR\ndesign = \"~condition + batch + condition:batch\"  # Model interaction\n```\n\n### No Significant Genes\n\n**Diagnostics:**\n```python\n# Check dispersion distribution\nplt.hist(dds.varm[\"dispersions\"], bins=50)\nplt.show()\n\n# Check size factors\nprint(dds.obsm[\"size_factors\"])\n\n# Look at top genes by raw p-value\nprint(ds.results_df.nsmallest(20, \"pvalue\"))\n```\n\n**Possible causes:**\n- Small effect sizes\n- High biological variability\n- Insufficient sample size\n- Technical issues (batch effects, outliers)\n\n## Reference Documentation\n\nFor comprehensive details beyond this workflow-oriented guide:\n\n- **API Reference** (`references\u002Fapi_reference.md`): Complete documentation of PyDESeq2 classes, methods, and data structures. Use when needing detailed parameter information or understanding object attributes.\n\n- **Workflow Guide** (`references\u002Fworkflow_guide.md`): In-depth guide covering complete analysis workflows, data loading patterns, multi-factor designs, troubleshooting, and best practices. Use when handling complex experimental designs or encountering issues.\n\nLoad these references into context when users need:\n- Detailed API documentation: `Read references\u002Fapi_reference.md`\n- Comprehensive workflow examples: `Read references\u002Fworkflow_guide.md`\n- Troubleshooting guidance: `Read references\u002Fworkflow_guide.md` (see Troubleshooting section)\n\n## Key Reminders\n\n1. **Data orientation matters:** Count matrices typically load as genes × samples but need to be samples × genes. Always transpose with `.T` if needed.\n\n2. **Sample filtering:** Remove samples with missing metadata before analysis to avoid errors.\n\n3. **Gene filtering:** Filter low-count genes (e.g., \u003C 10 total reads) to improve power and reduce computational time.\n\n4. **Design formula order:** Put adjustment variables before the variable of interest (e.g., `\"~batch + condition\"` not `\"~condition + batch\"`).\n\n5. **LFC shrinkage timing:** Apply shrinkage after statistical testing and only for visualization\u002Franking purposes. P-values remain based on unshrunken estimates.\n\n6. **Result interpretation:** Use `padj \u003C 0.05` for significance, not raw p-values. The Benjamini-Hochberg procedure controls false discovery rate.\n\n7. **Contrast specification:** The format is `[variable, test_level, reference_level]` where test_level is compared against reference_level.\n\n8. **Save intermediate objects:** Use pickle to save DeseqDataSet objects for later use or additional analyses without re-running the expensive fitting step.\n\n## Installation and Requirements\n\n```bash\nuv pip install pydeseq2\n```\n\n**System requirements:**\n- Python 3.10-3.11\n- pandas 1.4.3+\n- numpy 1.23.0+\n- scipy 1.11.0+\n- scikit-learn 1.1.1+\n- anndata 0.8.0+\n\n**Optional for visualization:**\n- matplotlib\n- seaborn\n\n## Additional Resources\n\n- **Official Documentation:** https:\u002F\u002Fpydeseq2.readthedocs.io\n- **GitHub Repository:** https:\u002F\u002Fgithub.com\u002Fowkin\u002FPyDESeq2\n- **Publication:** Muzellec et al. (2023) Bioinformatics, DOI: 10.1093\u002Fbioinformatics\u002Fbtad547\n- **Original DESeq2 (R):** Love et al. (2014) Genome Biology, DOI: 10.1186\u002Fs13059-014-0550-8\n\n",{"name":5,"license":39,"metadata":40,"description":7},"MIT license",{"skill-author":41},"K-Dense Inc.","master","c2e410e11df4d80d885e0ecf0583ef3c926df736","factory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpydeseq2",0,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory","https:\u002F\u002Fgithub.com\u002FiDorgham","Dorgham.me","hey I'm Dorgham \r\nI code, I create, and AI codes back. \r\nMaybe we can give AI the chance!! now we begin. 🚀🤖\r\n... . . . git commit -m \"Hello, Future\" ","2026-05-04 18:39:09",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add iDorgham\u002FWorkspace-Factory --skill pydeseq2",{"tool":57,"command":58},"bunx","bunx skills add iDorgham\u002FWorkspace-Factory --skill pydeseq2",{"tool":60,"command":61},"pnpm","pnpm dlx skills add iDorgham\u002FWorkspace-Factory --skill pydeseq2","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpydeseq2\u002FSKILL.md",true,[65,71,75,79],{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},"_AIWF_IMPORT.json","REFERENCE","参考文档",344,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpydeseq2\u002F_AIWF_IMPORT.json",{"path":72,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fapi_reference.md",7162,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpydeseq2\u002Freferences\u002Fapi_reference.md",{"path":76,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fworkflow_guide.md",13026,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpydeseq2\u002Freferences\u002Fworkflow_guide.md",{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},"scripts\u002Frun_deseq2_analysis.py","SCRIPT","脚本",11887,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fpydeseq2\u002Fscripts\u002Frun_deseq2_analysis.py",[86,119,141,163,183,206],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":97,"publishedAt":118},"01M71P8WVBMB2X3D24R0YT0B0E","vercel-react-view-transitions","Guide for implementing smooth, native-feeling animations using React's View Transition API (`\u003CViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter\u002Fexit of components, animate list reorder, implement directional (forward\u002Fback) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_vercel_labs_react_view_transitions\u002Fskill.md",[92],{"categoryNo":93,"categoryName":94,"taxonomyType":95,"taxonomyTypeDesc":96},"01JBSEEDCAT000000000000009","前端开发","SCENARIO","使用场景",[98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117],"react","vercel react view transitions","view","react view transitions","vercel","transitions","shared","back","Animation","css","types","states","element","implementing","when","components","api","route","create","libraries","2026-11-10 13:02:02",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":126,"publishedAt":118},"01M71P8TDGHZ289TSAC5VTG2EW","vercel-react-native-skills","React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_vercel_labs_react_native_skills\u002Fskill.md",[125],{"categoryNo":93,"categoryName":94,"taxonomyType":95,"taxonomyTypeDesc":96},[98,127,128,102,129,130,131,132,111,133,112,134,113,135,136,137,138,139,140,30],"react native","native","vercel react native skills","react native skills","modules","performance","apps","tasks","mobile","expo","list","mobile performance","platform","animations",{"skillNo":142,"name":143,"nameZh":6,"description":144,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":145,"categories":146,"keywords":148,"publishedAt":118},"01M71P8QK4JF5BYRGYDDGPZQG9","vercel-react-best-practices","React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React\u002FNext.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_vercel_labs_react_best_practices\u002Fskill.md",[147],{"categoryNo":93,"categoryName":94,"taxonomyType":95,"taxonomyTypeDesc":96},[98,149,150,102,151,132,152,112,153,134,113,154,155,156,157,158,159,160,161,162],"react best practices","vercel react best practices","best practices","writing","code","data fetching","react components","next","refactoring","data","patterns","Optimization","guidelines","triggers",{"skillNo":164,"name":165,"nameZh":6,"description":166,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":167,"categories":168,"keywords":170,"publishedAt":118},"01M71P8HVEA70K5N6ZVJCG2ED3","vercel-composition-patterns","React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_vercel_labs_composition_patterns\u002Fskill.md",[169],{"categoryNo":93,"categoryName":94,"taxonomyType":95,"taxonomyTypeDesc":96},[171,102,172,159,173,174,175,176,162,177,178,179,112,180,134,113,181,182,114,98],"Composition","composition patterns","vercel composition patterns","react composition patterns","react 19","render","boolean","component architecture","use","reusable","architecture","react composition",{"skillNo":184,"name":185,"nameZh":6,"description":186,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":187,"categories":188,"keywords":192,"publishedAt":118},"01M71P60XXKKP222ZFJRG7R373","supabase-postgres-best-practices","Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_supabase_supabase_postgres_best_practices\u002Fskill.md",[189],{"categoryNo":190,"categoryName":191,"taxonomyType":95,"taxonomyTypeDesc":96},"01JBSEEDCAT000000000000010","后端与接口",[193,194,195,196,151,197,198,199,30,160,132,200,201,152,202,179,203,204,205,112],"postgres best practices","supabase","postgres","supabase postgres best practices","categories","postgres performance","advanced","correct","schema","impact","Rules","critical","database",{"skillNo":207,"name":208,"nameZh":6,"description":209,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":210,"categories":211,"keywords":213,"publishedAt":229},"01M71P2ZCEJD0PKC458YTP1FJW","portable-text-serialization","Render and serialize Portable Text to React, Svelte, Vue, Astro, HTML, Markdown, and plain text. Use when implementing Portable Text rendering in any frontend framework, building custom serializers for non-standard block types, converting Portable Text to HTML strings server-side, converting Portable Text to Markdown, extracting plain text from Portable Text, or troubleshooting rendering issues with marks, blocks, lists, or custom types.","https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fofficial_sanity_io_portable_text_serialization\u002Fskill.md",[212],{"categoryNo":93,"categoryName":94,"taxonomyType":95,"taxonomyTypeDesc":96},[214,215,216,217,218,108,219,176,220,111,221,222,112,98,223,224,225,226,227,228],"text","portable text serialization","portable","serialization","extracting","strings","issues","frontend","svelte","sanity","astro","server","markdown","rendering","vue","2026-11-10 10:56:23"]