[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EFK2BT3X9MH3MZ58703VZV":3,"skill-same:01M7EFK2BT3X9MH3MZ58703VZV":68},{"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":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M7EFK2BT3X9MH3MZ58703VZV","bio-single-cell-markers-annotation",null,"Detect cluster marker genes and assign manual cell type labels in single-cell RNA-seq using Scanpy (Python) and Seurat (R). Use when finding genes that distinguish clusters, ranking markers for annotation, scoring gene signatures, hand-labeling clusters, or deciding between Wilcoxon marker ranking and pseudobulk condition DE.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-single-cell-markers-annotation\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-single-cell-markers-annotation\ndescription: Detect cluster marker genes and assign manual cell type labels in single-cell RNA-seq using Scanpy (Python) and Seurat (R). Use when finding genes that distinguish clusters, ranking markers for annotation, scoring gene signatures, hand-labeling clusters, or deciding between Wilcoxon marker ranking and pseudobulk condition DE.\ntool_type: mixed\nprimary_tool: Seurat\nsource: \"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills\"\nsource_repository: \"GPTomics\u002FbioSkills\"\nsource_path: \"single-cell\u002Fmarkers-annotation\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n\n## Version Compatibility\n\nReference examples tested with: scanpy 1.10+, Seurat 5.0+, anndata 0.10+\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- Python: `pip show \u003Cpackage>` then `help(module.function)` to check signatures\n- R: `packageVersion('\u003Cpkg>')` then `?function_name` to verify parameters\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed\npackage and adapt the example to match the actual API rather than retrying.\n\n# Marker Gene Detection and Manual Annotation\n\n**\"Find marker genes for my clusters\"** -> Rank genes that separate each cluster from the rest, then map clusters to cell types using canonical markers.\n- Python: `sc.tl.rank_genes_groups()` -> filter by effect size + fraction expressing -> `adata.obs[...].map(labels)`\n- R: `Seurat::FindAllMarkers()` -> filter by `avg_log2FC` + `pct.1`\u002F`pct.2` -> `RenameIdents()`\n\n## Governing principle\n\nMarker detection is descriptive ranking, NOT inference. Two distinct questions get sloppily called \"DE\" and must never be conflated: (1) marker detection - \"which genes are higher in cluster X vs the rest?\" is a ranking\u002Fannotation task where the cell is the unit and Wilcoxon is an acceptable heuristic; (2) condition DE - \"which genes change in cell type X between treated and control?\" is a population claim that requires biological replicates, where the unit of replication is the sample\u002Fdonor, not the cell. Question 2 must use pseudobulk (aggregate raw counts per sample x cell type, then DESeq2\u002FedgeR\u002Flimma-voom); treating cells as replicates is pseudoreplication and inflates false positives by orders of magnitude (Squair 2021).\nPost-clustering marker p-values are double-dipping. Clusters were defined to maximize between-group separation, so testing those same clusters for markers tests a hypothesis built from the data used to test it. The Wilcoxon\u002Ft-test null assumes fixed a-priori labels; under a single homogeneous population the statistic does not follow its nominal null, type-I error approaches 1 as resolution rises, and BH correction does nothing because the p-values are invalid before correction. Cluster-marker p-values are descriptive labels, never evidence that a cluster is a real cell type. Rank and filter markers by effect size and fraction-expressing, not by p-value; a gene can be \"significant\" at p=1e-40 (n is thousands) yet useless as a marker (60% in-group vs 55% out-group).\n\nThis skill covers marker discovery for clusters plus manual labeling. Automated reference-based label transfer (SingleR, CellTypist, Azimuth, scANVI) lives in single-cell\u002Fcell-annotation. Cross-condition compositional change lives in single-cell\u002Fdifferential-abundance.\n\n## Choosing a marker \u002F DE method\n\n| Method | Question answered | Use when | Fails when |\n|--------|-------------------|----------|------------|\n| Wilcoxon rank-sum (presto) | Rank cluster markers | Default for labeling a cluster vs rest; fast, non-parametric | Quoted as inference; double-dipping on the clustered data |\n| t-test | Rank cluster markers | Quick first pass; scanpy `method=None` default | Heavy-tailed sparse counts violate normality; less robust than Wilcoxon |\n| logistic regression (`logreg`\u002F`LR`) | Markers controlling covariates | Need to adjust for batch\u002Fcovariate when ranking | Slow; needs enough cells; still descriptive |\n| ROC (`roc`, Seurat) | Classification power per gene | Want an AUC ranking of marker discriminativeness | No p-value; pure ranking |\n| ClusterDE \u002F count splitting | Are the cluster's markers real (FDR-honest)? | Validating that a split is not spurious before naming it | Adds a synthetic-null \u002F data-thinning step; assumptions on the noise model |\n| Pseudobulk + DESeq2\u002FedgeR\u002Flimma-voom | Condition DE within a cell type | Treatment vs control with >=3 biological replicates per condition | n=1\u002Fcondition (dispersion unidentifiable); cells-as-replicates |\n\nMarker tools (`rank_genes_groups`, `FindMarkers`) will technically run a treatment-vs-control contrast cell-by-cell and return tidy tiny p-values. That is statistically invalid for a population claim. The tool not stopping the user is why this error is so common. When methods compete, verify current defaults against installed docs.\n\n## Defaults that bite (verify before trusting tutorials)\n\n| Tool | Folklore | Actual default |\n|------|----------|----------------|\n| scanpy `rank_genes_groups` | Defaults to Wilcoxon | `method=None` resolves to `t-test`; pass `method='wilcoxon'` explicitly |\n| Seurat v5 `FindMarkers` `logfc.threshold` | 0.25 | 0.1 in v5 (was 0.25 in v4); permissive, returns more hits |\n| Seurat v5 `FindMarkers` `min.pct` | 0.1 | 0.01 in v5 (was 0.1 in v4) |\n| Seurat `test.use='wilcox'` | Always fast | Fast only if `presto` is installed; else silent slow base-R fallback |\n| Pseudobulk input | Normalized\u002Flog values | Aggregate RAW counts (summed), never normalized |\n\n## Scanpy marker detection\n\n**Goal:** Rank cluster-specific markers and filter them by specificity, not p-value alone.\n\n**Approach:** Run Wilcoxon explicitly (scanpy's default is t-test), pull results to a DataFrame with `pts=True` for in\u002Fout fraction, then keep genes with a large positive log fold change and a high in-group \u002F low out-group fraction.\n\n```python\nimport scanpy as sc\n\nadata = sc.read_h5ad('clustered.h5ad')\n\nsc.tl.rank_genes_groups(adata, groupby='leiden', method='wilcoxon', pts=True, corr_method='benjamini-hochberg')\nmarkers = sc.get.rank_genes_groups_df(adata, group=None)\n\nspecific = markers[(markers['logfoldchanges'] > 1) & (markers['pct_nz_group'] > 0.5) & (markers['pct_nz_reference'] \u003C 0.25)]\nprint(specific.groupby('group').head(10)[['group', 'names', 'logfoldchanges', 'pct_nz_group', 'pct_nz_reference']])\n```\n\n## Seurat marker detection\n\n**Goal:** Rank markers per cluster and keep specific ones for labeling.\n\n**Approach:** Run `FindAllMarkers` with `only.pos=TRUE`, install presto so Wilcoxon is fast, then rank within cluster by `avg_log2FC` and require a `pct.1`-`pct.2` gap.\n\n```r\nlibrary(Seurat)\nlibrary(dplyr)\n\nall_markers \u003C- FindAllMarkers(seurat_obj, only.pos = TRUE, logfc.threshold = 0.25, min.pct = 0.1)\n\nspecific \u003C- all_markers %>%\n    filter(p_val_adj \u003C 0.05, avg_log2FC > 1, (pct.1 - pct.2) > 0.2) %>%\n    group_by(cluster) %>%\n    slice_max(n = 10, order_by = avg_log2FC)\nprint(specific)\n```\n\nSeurat v5 lowers thresholds to 0.1\u002F0.01, so explicit `logfc.threshold=0.25` and a `pct.1-pct.2` filter restore a marker-grade (specific) shortlist from a permissive run.\n\n## Gene signature scoring\n\n**Goal:** Score each cell for a curated panel without library-size confounding.\n\n**Approach:** Both tools subtract an expression-binned control set; thresholds are dataset-relative and must never be ported as absolute cutoffs.\n\n```python\nt_cell_panel = ['CD3D', 'CD3E', 'CD4', 'CD8A', 'CD8B']\nsc.tl.score_genes(adata, gene_list=t_cell_panel, ctrl_size=50, n_bins=25, score_name='T_cell_score')\n```\n\n```r\nseurat_obj \u003C- AddModuleScore(seurat_obj, features = list(c('CD3D', 'CD3E', 'CD4', 'CD8A', 'CD8B')), ctrl = 100, name = 'T_cell_score')\n```\n\nscanpy uses 25 control bins, Seurat uses 24 by default (both follow Tirosh 2016) - a real cross-ecosystem non-reproducibility source for small panels.\n\n## Cell-cycle scoring\n\n**Goal:** Assign each cell an S and G2\u002FM score and a phase, to diagnose (and optionally regress) cell-cycle-driven structure.\n\n**Approach:** Score the Tirosh S and G2\u002FM gene panels; both tools ship the lists. Regression is optional and confounded with biology (cycling is a real state in proliferating populations) - diagnose first and regress only when the cycle is a confound, not reflexively.\n\n```python\nsc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)\n```\n\n```r\nseurat_obj \u003C- CellCycleScoring(seurat_obj, s.features = cc.genes.updated.2019$s.genes, g2m.features = cc.genes.updated.2019$g2m.genes)\n```\n\nProvide `s_genes`\u002F`g2m_genes` as the Tirosh 2016 panels (Seurat's `cc.genes.updated.2019` exposes both lists directly); scanpy ships no built-in list, so load the panels from the reference or a regev-lab gene file.\n\n## Manual cluster labeling\n\n**Goal:** Map cluster ids to cell type names after marker inspection.\n\n**Approach:** Build a cluster->label dictionary from canonical-marker evidence, map it onto cells, and flag unmapped clusters rather than silently dropping them.\n\n```python\ncluster_labels = {'0': 'CD4 T', '1': 'CD14 Mono', '2': 'B', '3': 'CD8 T', '4': 'NK', '5': 'FCGR3A Mono'}\nadata.obs['cell_type'] = adata.obs['leiden'].map(cluster_labels).fillna('Unassigned')\n```\n\n```r\nnew_ids \u003C- c('0' = 'CD4 T', '1' = 'CD14 Mono', '2' = 'B', '3' = 'CD8 T', '4' = 'NK', '5' = 'FCGR3A Mono')\nseurat_obj \u003C- RenameIdents(seurat_obj, new_ids)\nseurat_obj$cell_type \u003C- Idents(seurat_obj)\n```\n\n## Condition DE the correct way (pseudobulk)\n\n**Goal:** Test which genes change between conditions within a cell type, with valid FDR.\n\n**Approach:** Aggregate RAW counts to one profile per sample x cell type, then hand the count matrix to a bulk engine (DESeq2\u002FedgeR\u002Flimma-voom) which estimates dispersion across biological replicates. Run each cell type separately so a one-cell-type effect is not diluted.\n\n```python\nimport scanpy as sc\n\ncell_type = adata[adata.obs['cell_type'] == 'CD14 Mono']\npseudobulk = sc.get.aggregate(cell_type, by='sample', func='sum')\ncounts_df = pseudobulk.layers['sum']\n```\n\n```r\npb \u003C- AggregateExpression(seurat_obj, group.by = c('cell_type', 'sample'), assays = 'RNA', layer = 'counts')$RNA\n```\n\nPull the summed counts slot, build a sample-level design (condition + covariates), and run DESeq2\u002FedgeR; see differential-expression\u002Fdeseq2-basics for the modeling step. Never run DE on batch-corrected or normalized expression.\n\n## Canonical PBMC markers (context-dependent, validate per dataset)\n\n| Cell type | Markers | Cell type | Markers |\n|-----------|---------|-----------|---------|\n| CD4 T | CD3D, CD4, IL7R | NK | NKG7, GNLY, NCAM1 |\n| CD8 T | CD3D, CD8A, CD8B | CD14 Mono | CD14, LYZ, S100A8 |\n| B | MS4A1, CD79A, CD19 | FCGR3A Mono | FCGR3A, MS4A7 |\n| DC | FCER1A, CST3 | Platelet | PPBP, PF4 |\n\nA marker is a conditional statement, not a property of a gene: a marker in blood may be expressed broadly in tumor, and \"vs rest\" markers depend on what \"rest\" is. Re-validate any ported panel.\n\n## Common Errors\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| Thousands of \"significant\" markers between two visually-similar clusters | Over-clustering + double-dipping inflation | Significance-test the split (scSHC\u002FClusterDE) or merge; never quote raw marker p-values as proof of a cell type |\n| Marker p-values used as evidence clusters are real | Selective-inference violation; BH cannot fix invalid p-values | Report markers as descriptive labels; validate identity with orthogonal markers |\n| Condition DE returns huge gene lists, none replicate | Cells treated as replicates (pseudoreplication) | Aggregate to pseudobulk per sample x cell type; test across donors |\n| `FindAllMarkers` hangs for minutes | presto not installed; slow base-R Wilcoxon | `install.packages('presto')` (or `remotes::install_github('immunogenomics\u002Fpresto')`) |\n| Same top markers in every cluster | Resolution too high; clusters split one population | Lower resolution \u002F merge; check stability |\n| Gene cutoff ported from another dataset misclassifies cells | Module scores are dataset-relative | Set thresholds from this dataset's score distribution |\n| NaN \u002F degenerate logFC and p-values from marker ranking | Only one cluster present, so the \"vs rest\" reference is empty | Marker ranking needs >=2 groups; subcluster the population or report it as a single homogeneous type |\n| \"DE genes\" between conditions but no gene changed per cell | Subpopulation proportions shifted (compositional confound) | Pair condition DE with single-cell\u002Fdifferential-abundance |\n\n## Related Skills\n\n- clustering - Cluster cells before finding markers\n- preprocessing - Normalize and select features before marker detection\n- cell-annotation - Automated reference-based label transfer (complements manual marker labeling)\n- differential-abundance - Test whether cell-type proportions changed between conditions\n- differential-expression\u002Fdeseq2-basics - Pseudobulk condition DE engine for the aggregated counts\n- differential-expression\u002Fde-results - Shrink, filter, and interpret pseudobulk DE results\n- pathway-analysis\u002Fgo-enrichment - Functional interpretation of marker \u002F DE gene lists\n\n## References\n\n- Squair et al. 2021, Nat Commun 12:5692 - cells-as-replicates inflate false positives; top DE methods aggregate to pseudobulk.\n- Crowell et al. 2020, Nat Commun 11:6077 - muscat; pseudobulk gives well-calibrated FDR for multi-sample multi-condition DS analysis.\n- Neufeld et al. 2024, Biostatistics 25(1):270-287 - count splitting \u002F valid post-clustering inference; Poisson thinning breaks under overdispersion.\n- Lee & Han 2024, Bioinformatics 40(8):btae498 - properly-offset pseudobulk is statistically equivalent to a GLMM.\n- Tirosh et al. 2016, Science 352:189-196 - control-set module scoring underlying score_genes \u002F AddModuleScore.\n","## Version Compatibility\n\nReference examples tested with: scanpy 1.10+, Seurat 5.0+, anndata 0.10+\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- Python: `pip show \u003Cpackage>` then `help(module.function)` to check signatures\n- R: `packageVersion('\u003Cpkg>')` then `?function_name` to verify parameters\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed\npackage and adapt the example to match the actual API rather than retrying.\n\n# Marker Gene Detection and Manual Annotation\n\n**\"Find marker genes for my clusters\"** -> Rank genes that separate each cluster from the rest, then map clusters to cell types using canonical markers.\n- Python: `sc.tl.rank_genes_groups()` -> filter by effect size + fraction expressing -> `adata.obs[...].map(labels)`\n- R: `Seurat::FindAllMarkers()` -> filter by `avg_log2FC` + `pct.1`\u002F`pct.2` -> `RenameIdents()`\n\n## Governing principle\n\nMarker detection is descriptive ranking, NOT inference. Two distinct questions get sloppily called \"DE\" and must never be conflated: (1) marker detection - \"which genes are higher in cluster X vs the rest?\" is a ranking\u002Fannotation task where the cell is the unit and Wilcoxon is an acceptable heuristic; (2) condition DE - \"which genes change in cell type X between treated and control?\" is a population claim that requires biological replicates, where the unit of replication is the sample\u002Fdonor, not the cell. Question 2 must use pseudobulk (aggregate raw counts per sample x cell type, then DESeq2\u002FedgeR\u002Flimma-voom); treating cells as replicates is pseudoreplication and inflates false positives by orders of magnitude (Squair 2021).\nPost-clustering marker p-values are double-dipping. Clusters were defined to maximize between-group separation, so testing those same clusters for markers tests a hypothesis built from the data used to test it. The Wilcoxon\u002Ft-test null assumes fixed a-priori labels; under a single homogeneous population the statistic does not follow its nominal null, type-I error approaches 1 as resolution rises, and BH correction does nothing because the p-values are invalid before correction. Cluster-marker p-values are descriptive labels, never evidence that a cluster is a real cell type. Rank and filter markers by effect size and fraction-expressing, not by p-value; a gene can be \"significant\" at p=1e-40 (n is thousands) yet useless as a marker (60% in-group vs 55% out-group).\n\nThis skill covers marker discovery for clusters plus manual labeling. Automated reference-based label transfer (SingleR, CellTypist, Azimuth, scANVI) lives in single-cell\u002Fcell-annotation. Cross-condition compositional change lives in single-cell\u002Fdifferential-abundance.\n\n## Choosing a marker \u002F DE method\n\n| Method | Question answered | Use when | Fails when |\n|--------|-------------------|----------|------------|\n| Wilcoxon rank-sum (presto) | Rank cluster markers | Default for labeling a cluster vs rest; fast, non-parametric | Quoted as inference; double-dipping on the clustered data |\n| t-test | Rank cluster markers | Quick first pass; scanpy `method=None` default | Heavy-tailed sparse counts violate normality; less robust than Wilcoxon |\n| logistic regression (`logreg`\u002F`LR`) | Markers controlling covariates | Need to adjust for batch\u002Fcovariate when ranking | Slow; needs enough cells; still descriptive |\n| ROC (`roc`, Seurat) | Classification power per gene | Want an AUC ranking of marker discriminativeness | No p-value; pure ranking |\n| ClusterDE \u002F count splitting | Are the cluster's markers real (FDR-honest)? | Validating that a split is not spurious before naming it | Adds a synthetic-null \u002F data-thinning step; assumptions on the noise model |\n| Pseudobulk + DESeq2\u002FedgeR\u002Flimma-voom | Condition DE within a cell type | Treatment vs control with >=3 biological replicates per condition | n=1\u002Fcondition (dispersion unidentifiable); cells-as-replicates |\n\nMarker tools (`rank_genes_groups`, `FindMarkers`) will technically run a treatment-vs-control contrast cell-by-cell and return tidy tiny p-values. That is statistically invalid for a population claim. The tool not stopping the user is why this error is so common. When methods compete, verify current defaults against installed docs.\n\n## Defaults that bite (verify before trusting tutorials)\n\n| Tool | Folklore | Actual default |\n|------|----------|----------------|\n| scanpy `rank_genes_groups` | Defaults to Wilcoxon | `method=None` resolves to `t-test`; pass `method='wilcoxon'` explicitly |\n| Seurat v5 `FindMarkers` `logfc.threshold` | 0.25 | 0.1 in v5 (was 0.25 in v4); permissive, returns more hits |\n| Seurat v5 `FindMarkers` `min.pct` | 0.1 | 0.01 in v5 (was 0.1 in v4) |\n| Seurat `test.use='wilcox'` | Always fast | Fast only if `presto` is installed; else silent slow base-R fallback |\n| Pseudobulk input | Normalized\u002Flog values | Aggregate RAW counts (summed), never normalized |\n\n## Scanpy marker detection\n\n**Goal:** Rank cluster-specific markers and filter them by specificity, not p-value alone.\n\n**Approach:** Run Wilcoxon explicitly (scanpy's default is t-test), pull results to a DataFrame with `pts=True` for in\u002Fout fraction, then keep genes with a large positive log fold change and a high in-group \u002F low out-group fraction.\n\n```python\nimport scanpy as sc\n\nadata = sc.read_h5ad('clustered.h5ad')\n\nsc.tl.rank_genes_groups(adata, groupby='leiden', method='wilcoxon', pts=True, corr_method='benjamini-hochberg')\nmarkers = sc.get.rank_genes_groups_df(adata, group=None)\n\nspecific = markers[(markers['logfoldchanges'] > 1) & (markers['pct_nz_group'] > 0.5) & (markers['pct_nz_reference'] \u003C 0.25)]\nprint(specific.groupby('group').head(10)[['group', 'names', 'logfoldchanges', 'pct_nz_group', 'pct_nz_reference']])\n```\n\n## Seurat marker detection\n\n**Goal:** Rank markers per cluster and keep specific ones for labeling.\n\n**Approach:** Run `FindAllMarkers` with `only.pos=TRUE`, install presto so Wilcoxon is fast, then rank within cluster by `avg_log2FC` and require a `pct.1`-`pct.2` gap.\n\n```r\nlibrary(Seurat)\nlibrary(dplyr)\n\nall_markers \u003C- FindAllMarkers(seurat_obj, only.pos = TRUE, logfc.threshold = 0.25, min.pct = 0.1)\n\nspecific \u003C- all_markers %>%\n    filter(p_val_adj \u003C 0.05, avg_log2FC > 1, (pct.1 - pct.2) > 0.2) %>%\n    group_by(cluster) %>%\n    slice_max(n = 10, order_by = avg_log2FC)\nprint(specific)\n```\n\nSeurat v5 lowers thresholds to 0.1\u002F0.01, so explicit `logfc.threshold=0.25` and a `pct.1-pct.2` filter restore a marker-grade (specific) shortlist from a permissive run.\n\n## Gene signature scoring\n\n**Goal:** Score each cell for a curated panel without library-size confounding.\n\n**Approach:** Both tools subtract an expression-binned control set; thresholds are dataset-relative and must never be ported as absolute cutoffs.\n\n```python\nt_cell_panel = ['CD3D', 'CD3E', 'CD4', 'CD8A', 'CD8B']\nsc.tl.score_genes(adata, gene_list=t_cell_panel, ctrl_size=50, n_bins=25, score_name='T_cell_score')\n```\n\n```r\nseurat_obj \u003C- AddModuleScore(seurat_obj, features = list(c('CD3D', 'CD3E', 'CD4', 'CD8A', 'CD8B')), ctrl = 100, name = 'T_cell_score')\n```\n\nscanpy uses 25 control bins, Seurat uses 24 by default (both follow Tirosh 2016) - a real cross-ecosystem non-reproducibility source for small panels.\n\n## Cell-cycle scoring\n\n**Goal:** Assign each cell an S and G2\u002FM score and a phase, to diagnose (and optionally regress) cell-cycle-driven structure.\n\n**Approach:** Score the Tirosh S and G2\u002FM gene panels; both tools ship the lists. Regression is optional and confounded with biology (cycling is a real state in proliferating populations) - diagnose first and regress only when the cycle is a confound, not reflexively.\n\n```python\nsc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)\n```\n\n```r\nseurat_obj \u003C- CellCycleScoring(seurat_obj, s.features = cc.genes.updated.2019$s.genes, g2m.features = cc.genes.updated.2019$g2m.genes)\n```\n\nProvide `s_genes`\u002F`g2m_genes` as the Tirosh 2016 panels (Seurat's `cc.genes.updated.2019` exposes both lists directly); scanpy ships no built-in list, so load the panels from the reference or a regev-lab gene file.\n\n## Manual cluster labeling\n\n**Goal:** Map cluster ids to cell type names after marker inspection.\n\n**Approach:** Build a cluster->label dictionary from canonical-marker evidence, map it onto cells, and flag unmapped clusters rather than silently dropping them.\n\n```python\ncluster_labels = {'0': 'CD4 T', '1': 'CD14 Mono', '2': 'B', '3': 'CD8 T', '4': 'NK', '5': 'FCGR3A Mono'}\nadata.obs['cell_type'] = adata.obs['leiden'].map(cluster_labels).fillna('Unassigned')\n```\n\n```r\nnew_ids \u003C- c('0' = 'CD4 T', '1' = 'CD14 Mono', '2' = 'B', '3' = 'CD8 T', '4' = 'NK', '5' = 'FCGR3A Mono')\nseurat_obj \u003C- RenameIdents(seurat_obj, new_ids)\nseurat_obj$cell_type \u003C- Idents(seurat_obj)\n```\n\n## Condition DE the correct way (pseudobulk)\n\n**Goal:** Test which genes change between conditions within a cell type, with valid FDR.\n\n**Approach:** Aggregate RAW counts to one profile per sample x cell type, then hand the count matrix to a bulk engine (DESeq2\u002FedgeR\u002Flimma-voom) which estimates dispersion across biological replicates. Run each cell type separately so a one-cell-type effect is not diluted.\n\n```python\nimport scanpy as sc\n\ncell_type = adata[adata.obs['cell_type'] == 'CD14 Mono']\npseudobulk = sc.get.aggregate(cell_type, by='sample', func='sum')\ncounts_df = pseudobulk.layers['sum']\n```\n\n```r\npb \u003C- AggregateExpression(seurat_obj, group.by = c('cell_type', 'sample'), assays = 'RNA', layer = 'counts')$RNA\n```\n\nPull the summed counts slot, build a sample-level design (condition + covariates), and run DESeq2\u002FedgeR; see differential-expression\u002Fdeseq2-basics for the modeling step. Never run DE on batch-corrected or normalized expression.\n\n## Canonical PBMC markers (context-dependent, validate per dataset)\n\n| Cell type | Markers | Cell type | Markers |\n|-----------|---------|-----------|---------|\n| CD4 T | CD3D, CD4, IL7R | NK | NKG7, GNLY, NCAM1 |\n| CD8 T | CD3D, CD8A, CD8B | CD14 Mono | CD14, LYZ, S100A8 |\n| B | MS4A1, CD79A, CD19 | FCGR3A Mono | FCGR3A, MS4A7 |\n| DC | FCER1A, CST3 | Platelet | PPBP, PF4 |\n\nA marker is a conditional statement, not a property of a gene: a marker in blood may be expressed broadly in tumor, and \"vs rest\" markers depend on what \"rest\" is. Re-validate any ported panel.\n\n## Common Errors\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| Thousands of \"significant\" markers between two visually-similar clusters | Over-clustering + double-dipping inflation | Significance-test the split (scSHC\u002FClusterDE) or merge; never quote raw marker p-values as proof of a cell type |\n| Marker p-values used as evidence clusters are real | Selective-inference violation; BH cannot fix invalid p-values | Report markers as descriptive labels; validate identity with orthogonal markers |\n| Condition DE returns huge gene lists, none replicate | Cells treated as replicates (pseudoreplication) | Aggregate to pseudobulk per sample x cell type; test across donors |\n| `FindAllMarkers` hangs for minutes | presto not installed; slow base-R Wilcoxon | `install.packages('presto')` (or `remotes::install_github('immunogenomics\u002Fpresto')`) |\n| Same top markers in every cluster | Resolution too high; clusters split one population | Lower resolution \u002F merge; check stability |\n| Gene cutoff ported from another dataset misclassifies cells | Module scores are dataset-relative | Set thresholds from this dataset's score distribution |\n| NaN \u002F degenerate logFC and p-values from marker ranking | Only one cluster present, so the \"vs rest\" reference is empty | Marker ranking needs >=2 groups; subcluster the population or report it as a single homogeneous type |\n| \"DE genes\" between conditions but no gene changed per cell | Subpopulation proportions shifted (compositional confound) | Pair condition DE with single-cell\u002Fdifferential-abundance |\n\n## Related Skills\n\n- clustering - Cluster cells before finding markers\n- preprocessing - Normalize and select features before marker detection\n- cell-annotation - Automated reference-based label transfer (complements manual marker labeling)\n- differential-abundance - Test whether cell-type proportions changed between conditions\n- differential-expression\u002Fdeseq2-basics - Pseudobulk condition DE engine for the aggregated counts\n- differential-expression\u002Fde-results - Shrink, filter, and interpret pseudobulk DE results\n- pathway-analysis\u002Fgo-enrichment - Functional interpretation of marker \u002F DE gene lists\n\n## References\n\n- Squair et al. 2021, Nat Commun 12:5692 - cells-as-replicates inflate false positives; top DE methods aggregate to pseudobulk.\n- Crowell et al. 2020, Nat Commun 11:6077 - muscat; pseudobulk gives well-calibrated FDR for multi-sample multi-condition DS analysis.\n- Neufeld et al. 2024, Biostatistics 25(1):270-287 - count splitting \u002F valid post-clustering inference; Poisson thinning breaks under overdispersion.\n- Lee & Han 2024, Bioinformatics 40(8):btae498 - properly-offset pseudobulk is statistically equivalent to a GLMM.\n- Tirosh et al. 2016, Science 352:189-196 - control-set module scoring underlying score_genes \u002F AddModuleScore.\n",{"name":5,"source":24,"license":15,"tool_type":25,"description":7,"imported_at":26,"source_path":27,"primary_tool":28,"source_repository":29},"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills","mixed","2026-09-20","single-cell\u002Fmarkers-annotation\u002FSKILL.md","Seurat","GPTomics\u002FbioSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fbiology\u002Fbio-single-cell-markers-annotation","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-single-cell-markers-annotation",{"tool":42,"command":43},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-single-cell-markers-annotation",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-single-cell-markers-annotation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-single-cell-markers-annotation\u002FSKILL.md",true,[50,56,62],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Ffind_markers_scanpy.py","SCRIPT","脚本",1007,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-single-cell-markers-annotation\u002Fexamples\u002Ffind_markers_scanpy.py",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"examples\u002Ffind_markers_seurat.R","OTHER","其他",1334,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-single-cell-markers-annotation\u002Fexamples\u002Ffind_markers_seurat.R",{"path":63,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"usage-guide.md","REFERENCE","参考文档",3257,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-single-cell-markers-annotation\u002Fusage-guide.md",[69,77,84,91,98,105],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":76},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":76},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":76},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":76},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":76},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":76},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]