Skip to content

Commit 4824964

Browse files
committed
fix atac h5ad
1 parent 4448b1d commit 4824964

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

pipelines/wdl/scanvi/scANVI.wdl

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,36 @@ task MultiomeLabelTransfer {
128128
LOCALIZE_FLAG="--localize"
129129
fi
130130
131-
# Ensure GEX h5ad has 'star_IsCell' column (required by the script).
132-
# If missing, add it with all True so the filter is a no-op.
131+
# Ensure GEX h5ad has 'star_IsCell' column and ATAC h5ad has 'gex_barcodes'
132+
# column (both required by the script). If missing, add sensible defaults.
133133
python3 -c "
134134
import scanpy as sc
135+
import snapatac2 as snap
135136
import os
136137
138+
# Patch GEX: add star_IsCell if missing (makes the cell filter a no-op)
137139
gex_path = '$GEX_FILE'
138-
# Only patch local files (not GCS paths handled by --localize)
139140
if not gex_path.startswith('gs://') and os.path.exists(gex_path):
140-
adata = sc.read_h5ad(gex_path)
141-
if 'star_IsCell' not in adata.obs.columns:
141+
gex = sc.read_h5ad(gex_path)
142+
if 'star_IsCell' not in gex.obs.columns:
142143
print('Adding missing star_IsCell column (all True) to GEX h5ad')
143-
adata.obs['star_IsCell'] = True
144-
adata.write(gex_path)
144+
gex.obs['star_IsCell'] = True
145+
gex.write(gex_path)
145146
print('Patched GEX h5ad saved')
146147
else:
147148
print('star_IsCell column already present')
149+
150+
# Patch ATAC: add gex_barcodes if missing (uses existing obs index as barcodes)
151+
atac_path = '$ATAC_FILE'
152+
if not atac_path.startswith('gs://') and os.path.exists(atac_path):
153+
atac = snap.read(atac_path, backed=None)
154+
if 'gex_barcodes' not in atac.obs.columns:
155+
print('Adding missing gex_barcodes column (copy of obs index) to ATAC h5ad')
156+
atac.obs['gex_barcodes'] = atac.obs.index
157+
atac.write(atac_path)
158+
print('Patched ATAC h5ad saved')
159+
else:
160+
print('gex_barcodes column already present')
148161
"
149162
150163
python3 /usr/local/multiome_label_transfer.py \

0 commit comments

Comments
 (0)