depmap-crispr-essentiality — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited depmap-crispr-essentiality (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
This guide covers the correct interpretation and analysis of DepMap CRISPR gene effect (Chronos) data. The most critical and common error in DepMap analyses is failing to negate the CRISPR scores when computing correlations with "essentiality." A secondary but equally damaging mistake is using bulk correlation shortcuts that mishandle per-gene NaN patterns. This guide provides the mandatory sign convention, the correct per-gene NaN-safe Spearman correlation implementation, and data loading/alignment procedures.
The CRISPR gene effect score (produced by the Chronos algorithm) quantifies how gene knockout affects cell viability:
The DepMap portal distributes these scores in the file CRISPRGeneEffect.csv. Each row is a cell line (DepMap ID, e.g., ACH-000001) and each column is a gene in the format GENE_NAME (ENTREZ_ID), e.g., A1BG (1).
Because negative raw scores indicate essentiality, any analysis that asks about "essentiality" or "dependency" requires negating the raw CRISPR scores:
-CRISPRGeneEffect (negated)If you correlate expression with raw CRISPR scores and find 3 genes with correlation <= -0.6 and 0 genes with correlation >= 0.6, then the correct answer for "genes with strong positive correlation with essentiality" is 3, not 0. The negative correlations with raw scores ARE the positive correlations with essentiality.
The standard DepMap data files use a consistent structure:
ACH-XXXXXX)GENE_NAME (ENTREZ_ID) formatOmicsExpressionProteinCodingGenesTPMLogp1BatchCorrected.csv) uses the same index/column format, enabling direct alignmentDifferent genes have different patterns of missing data across cell lines. This is because not all genes are screened in all cell lines, and quality control may remove specific gene-cell line combinations.
Question: How should I compute correlations with DepMap CRISPR data?
├── Does the question mention "essentiality" or "dependency"?
│ ├── Yes → Negate CRISPR scores before correlating (see Best Practices #1)
│ └── No (raw gene effect) → Use raw scores directly
├── How should I compute correlations?
│ ├── Per-gene correlation → scipy.stats.spearmanr in a loop (see Best Practices #2)
│ └── Matrix-wide correlation → AVOID; use per-gene loop instead
└── How should I handle missing data?
├── Pairwise NaN removal → CORRECT (see Best Practices #3)
└── Global row/column dropping → INCORRECT; loses too much data| Scenario | Recommended Approach | Rationale |
|---|---|---|
| Correlating expression with "essentiality" | Negate CRISPR scores, then per-gene Spearman | Sign convention requires negation; per-gene handles NaN correctly |
| Correlating expression with raw gene effect | Per-gene Spearman on raw scores | No negation needed, but NaN-safe per-gene loop still required |
| Ranking genes by essentiality across cell lines | Rank by most negative mean raw score | More negative = more essential across the panel |
| Identifying selectively essential genes | Compare score distributions across subgroups | Use per-subgroup mean/median of raw scores, then compare |
| Filtering genes before correlation | Require minimum 10 valid cell line pairs | Genes with too few observations yield unreliable correlations |
DataFrame.corrwith, DataFrame.rank().corrwith()) handle NaN inconsistently across columns. The only reliable method is to compute Spearman correlation gene by gene using scipy.stats.spearmanr with pairwise-complete observations.# Negate: in DepMap, negative = essential.DataFrame.corrwith(method='spearman') or DataFrame.rank().corrwith() silently mishandle NaN values, potentially shifting correlations enough to push genes above or below significance thresholds.scipy.stats.spearmanr. See the reference implementation in the Workflow section below.dropna() on the entire DataFrame before correlation removes all cell lines that have any NaN in any gene, drastically reducing sample size.mask = ~(np.isnan(x) | np.isnan(y)). This preserves the maximum number of observations per gene.if mask.sum() < 10: continue. Adjust the threshold upward (e.g., 20) for more conservative analysis.common_lines = expr.index.intersection(crispr.index) and common_genes = expr.columns.intersection(crispr.columns), then subset both DataFrames before any computation.GENE_NAME (ENTREZ_ID). Attempting to match against plain gene symbols (e.g., TP53 instead of TP53 (7157)) will produce empty intersections.df.columns[:5] before attempting any join or intersection. Parse gene names if needed: df.columns.str.extract(r'^(.+?)\s*\(')[0]. import pandas as pd
# Load CRISPR gene effect data
crispr = pd.read_csv('CRISPRGeneEffect.csv', index_col=0)
# Load expression data
expr = pd.read_csv(
'OmicsExpressionProteinCodingGenesTPMLogp1BatchCorrected.csv',
index_col=0
)
# Column format: "GENE_NAME (ENTREZ_ID)" e.g., "A1BG (1)"
# Index: DepMap cell line IDs e.g., "ACH-000001" # Find common cell lines and genes
common_lines = crispr.index.intersection(expr.index)
common_genes = crispr.columns.intersection(expr.columns)
print(f"Common cell lines: {len(common_lines)}")
print(f"Common genes: {len(common_genes)}")
# Subset to common
crispr_aligned = crispr.loc[common_lines, common_genes]
expr_aligned = expr.loc[common_lines, common_genes] expr_nan = expr_aligned.isna().sum().sum()
crispr_nan = crispr_aligned.isna().sum().sum()
print(f"Expression NaN count: {expr_nan}")
print(f"CRISPR NaN count: {crispr_nan}") # Negate: in DepMap, negative raw score = essential
# After negation, positive = essential
essentiality = -crispr_aligned from scipy.stats import spearmanr
import numpy as np
def compute_per_gene_spearman(expression_df, crispr_df, negate_crispr=True):
"""Compute Spearman correlation per gene with proper NaN handling.
Args:
expression_df: DataFrame (cell_lines x genes)
crispr_df: DataFrame (cell_lines x genes)
negate_crispr: If True, negate CRISPR scores to represent essentiality
Returns:
Series of Spearman correlations indexed by gene name
"""
# Align cell lines and genes
common_lines = expression_df.index.intersection(crispr_df.index)
common_genes = expression_df.columns.intersection(crispr_df.columns)
expr = expression_df.loc[common_lines, common_genes]
crispr = crispr_df.loc[common_lines, common_genes]
if negate_crispr:
crispr = -crispr
# Print NaN summary BEFORE analysis
expr_nan = expr.isna().sum().sum()
crispr_nan = crispr.isna().sum().sum()
print(f"Expression NaN count: {expr_nan}")
print(f"CRISPR NaN count: {crispr_nan}")
print(f"Common cell lines: {len(common_lines)}")
print(f"Common genes: {len(common_genes)}")
# Per-gene Spearman correlation with pairwise NaN removal
correlations = {}
for gene in common_genes:
x = expr[gene].values
y = crispr[gene].values
# Remove pairs where either value is NaN
mask = ~(np.isnan(x) | np.isnan(y))
if mask.sum() < 10: # Skip genes with too few valid pairs
continue
rho, pval = spearmanr(x[mask], y[mask])
correlations[gene] = rho
return pd.Series(correlations).sort_values(ascending=False) correlations = compute_per_gene_spearman(expr_aligned, crispr_aligned,
negate_crispr=True)
threshold = 0.6
strong_positive = correlations[correlations >= threshold]
strong_negative = correlations[correlations <= -threshold]
print(f"Genes with correlation >= {threshold}: {len(strong_positive)}")
print(f"Genes with correlation <= -{threshold}: {len(strong_negative)}")
print(f"\nNote: CRISPR scores were negated so that positive correlation")
print(f"indicates higher expression associated with greater essentiality.")Verify that none of these bulk shortcuts were used anywhere in the analysis:
# WRONG: Bulk rank-then-correlate shortcut
ranked_expr = expression_df.rank()
ranked_crispr = crispr_df.rank()
correlations = ranked_expr.corrwith(ranked_crispr) # NaN handling is unreliable
# WRONG: Bulk corrwith with method='spearman'
correlations = expression_df.corrwith(crispr_df, method='spearman') # Same issueIf any of these patterns appear in the code, replace them with the per-gene loop from Step 5.
nan-safe-correlation -- General techniques for NaN-safe correlation computation across omics datasets; this guide applies those principles specifically to DepMap CRISPR datadegenerate-input-filtering -- Upstream data quality filtering to remove low-variance or degenerate features before correlation analysis; recommended as a preprocessing step before DepMap essentiality correlation~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.