mcmicro_to_scimap
mcmicro_to_scimap ¶
mcmicro_to_scimap(
featureTablePath,
removeDna=True,
removeStringFromName=None,
log=True,
dropMarkers=None,
randomSample=None,
uniqueCellId=True,
cellId="CellID",
split="X_centroid",
customImageid=None,
minCells=None,
verbose=True,
outputDir=None,
maxWorkers=None,
chunk_size=10000,
)
Read mcmicro quantification CSVs into an AnnData.
An mcmicro feature table is one row per cell: marker intensities first, then
morphology and position columns. split names the first non-marker column, so
everything before it becomes var and everything from it onward becomes obs.
Several files can be read at once and are concatenated, with imageid taken
from each file's name. Reading is chunked and parallel.
The result carries raw intensities in .raw.X, a log1p copy in .X when
log=True, and X_centroid / Y_centroid / Area / CellID / imageid in
obs.
Note this is the one function whose first parameter is not data — there is no
cell table yet, only files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
featureTablePath
|
(str | list, required)
|
Path to one mcmicro quantification CSV, or a list of them. |
required |
removeDna
|
bool
|
Drop the nuclear counterstain channels — any marker whose name
contains |
True
|
removeStringFromName
|
str
|
Substring to strip from every marker name, for cleaning up
|
None
|
log
|
bool
|
Put a |
True
|
dropMarkers
|
list
|
Markers to drop while reading. |
None
|
randomSample
|
int
|
Randomly subsample to this many cells. Useful for prototyping on a big slide. |
None
|
uniqueCellId
|
bool
|
Prefix cell names with their image id, so names stay unique when several files are concatenated. Leave this on for multi-image objects. |
True
|
cellId
|
str
|
Column holding the per-cell identifier. |
'CellID'
|
split
|
str
|
The first non-marker column. Everything before it is treated as a marker, everything from it as metadata. |
'X_centroid'
|
customImageid
|
str
|
Use this as the image id instead of deriving it from the file name. |
None
|
minCells
|
int
|
Skip any file with fewer than this many cells. |
None
|
verbose
|
bool
|
Print progress messages. |
True
|
outputDir
|
str
|
Directory to write the resulting |
None
|
maxWorkers
|
int
|
Workers for the parallel read. Defaults to |
None
|
chunk_size
|
int
|
Rows per chunk while reading. |
10000
|
Returns:
| Name | Type | Description |
|---|---|---|
adata |
AnnData | None
|
The assembled cell table. |
Example
adata = sp.pp.mcmicro_to_scimap("quantification/unmicst-exemplar.csv")
# Several images at once, with tidy marker names.
adata = sp.pp.mcmicro_to_scimap(
["quantification/sample_1.csv", "quantification/sample_2.csv"],
removeStringFromName="_cellRingMask",
removeDna=True,
)
adata.obs["imageid"].value_counts()
# Prototype on 20,000 cells.
adata = sp.pp.mcmicro_to_scimap("quantification/big.csv", randomSample=20000)