neuralib.atlas.ccf.dataframe.RoiClassifierDataFrame
- class neuralib.atlas.ccf.dataframe.RoiClassifierDataFrame[source]
Bases:
DataFrameWrapperRoiClassifierDataFrame with each roi (rows)
- Required fields:
acronym- area acronymAP_location: anterior-posterior coordinates (mm)DV_location: dorsal-ventral coordinates (mm)ML_location: medial-lateral coordinates (mm)channel: fluorescence channel (i.e., gfp, rfp, mcherry, …)source: source name (i.e., if circuit tracing, you can give source tracing area…)
- __init__(df, *, cached_dir=None, invalid_post_processing_cache=False)[source]
- Parameters:
df (DataFrame) – DataFrame with required fields
cached_dir (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader | None) – create cached directory
invalid_post_processing_cache (bool) – invalid post processing cache if cached_dir is not None
- dataframe(dataframe=None, may_inplace=True)[source]
Getter/setter for the internal Polars DataFrame.
- Parameters:
dataframe (DataFrame | None) – Optional new dataframe to set.
may_inplace – If True, update current instance. Otherwise, return new instance.
- Returns:
The current dataframe or a modified wrapper instance.
- property channels: list[str]
list of channel names
- property n_channels: int
number of channel
- property channel_counts: DataFrame
channel counts dataframe
- property source_counts: DataFrame
source counts dataframe
- property sources: list[str]
list of source names
- property n_sources: int
number of source
- property is_overlapped_channel: bool
whether there is overlapped channel
- get_channel_source_dict()[source]
get channel (key): source (value) dict
- Return type:
dict[str, str]
- get_classified_column(field, strict=True)[source]
classified column name, with the given
- Parameters:
field (int | str | None) – int:
tree_[level]; str:get column; None:acronymstrict (bool) – strict check for the pre-defined classified column
- Return type:
str
- post_processing(*, filter_capital=True, tree=True, family=True, hemisphere=True, copy_overlap=True, filter_injection=None)[source]
Load the post-processing dataframe
- Parameters:
filter_capital (bool) – filter only
acronymcontain capital letterstree (bool) – with customized hierarchical tree structure based on allen brain
family (bool) – with column
family(‘HB’, ‘HY’, ‘TH’, ‘MB’, ‘CB’, ‘CTXpl’, ‘HPF’, ‘ISOCORTEX’, ‘OLF’, ‘CTXsp’hemisphere (bool) – with column
hemispherewith which hemispherecopy_overlap (bool) – Copy overlap channels counts to individual channels, only set true if overlapped roi is not counted for individual channels
filter_injection (tuple[str, str] | None) – filter out the injection site labelled
- Returns:
- Return type:
Self
- filter_injection_site(area, hemisphere)[source]
filter out the injection site labelled
- Parameters:
area (str) – brain area
hemisphere (str) – which hemisphere
- Returns:
- Return type:
Self
- with_tree_columns()[source]
with customized hierarchical tree structure based on allen brain
See also
Wang et al 2020, https://doi.org/10.1016/j.cell.2020.04.007
- Return type:
Self
- with_family_columns()[source]
with column
family(‘HB’, ‘HY’, ‘TH’, ‘MB’, ‘CB’, ‘CTXpl’, ‘HPF’, ‘ISOCORTEX’, ‘OLF’, ‘CTXsp’)- Return type:
Self
- with_hemisphere_column(invert=False)[source]
with column
hemispherewith which hemisphere- Parameters:
invert (bool) – invert hemisphere. Default ML >= 0 (ipsi), ML < 0 (contra)
- Returns:
- Return type:
Self
- with_overlap_copy()[source]
Copy overlap channels counts to individual channels, only used if overlapped roi is not counted for individual channels
- Return type:
Self
- to_normalized(norm, level, *, source=None, top_area=None, rest_as_others=False, hemisphere='both', animal=None, volume_norm_backend='cellatlas')[source]
To the normalized dataframe (example as volume normalized)
┌─────────┬────────┬────────┬───────────┬────────────┬────────────────┬────────────┐ │ source ┆ tree_2 ┆ counts ┆ fraction ┆ hemisphere ┆ Volumes [mm^3] ┆ normalized │ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ str ┆ u32 ┆ f64 ┆ str ┆ f64 ┆ f64 │ ╞═════════╪════════╪════════╪═══════════╪════════════╪════════════════╪════════════╡ │ overlap ┆ ACA ┆ 1208 ┆ 29.997517 ┆ both ┆ 5.222484 ┆ 231.307537 │ │ pRSC ┆ ACA ┆ 3296 ┆ 22.822324 ┆ both ┆ 5.222484 ┆ 631.117254 │ │ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │ │ pRSC ┆ VIS ┆ 4035 ┆ 27.939344 ┆ both ┆ 12.957203 ┆ 311.409797 │ │ overlap ┆ VIS ┆ 628 ┆ 15.594736 ┆ both ┆ 12.957203 ┆ 48.46725 │ │ aRSC ┆ VIS ┆ 3865 ┆ 12.627005 ┆ both ┆ 12.957203 ┆ 298.289682 │ └─────────┴────────┴────────┴───────────┴────────────┴────────────────┴────────────┘
- Parameters:
norm (Literal['channel', 'volume', 'cell', 'none']) –
ROIS_NORM_TYPElevel (int | str | None) – tree level for determine which level of classified column
source (str | None) – filter only the given
sourcetop_area (int | None) – filter only the given top areas (sorted based on
fraction)rest_as_others (bool) – vertical concat a region called other with the roi filtered by
top areahemisphere (Literal['ipsi', 'contra', 'both']) – filter only the given
hemisphereanimal (str | None) – with animal id column
animalvolume_norm_backend (Literal['cellatlas', 'brainglobe']) – volume normalization backend. {‘cellatlas’, ‘brainglobe’}
- Returns:
RoiNormalizedDataFrame- Return type:
- to_subregion(region, *, unit='fraction', source_order=None, show_col=None, animal=None)[source]
To the subregion dataframe (example as Visual region: VIS)
┌─────────┬───────────┬───────────┬───────────┬───┬──────────┬──────────┬──────────┬──────────┐ │ source ┆ VISam ┆ VISp ┆ VISpm ┆ … ┆ VISal ┆ VISpor ┆ VISli ┆ VISpl │ │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │ │ str ┆ f64 ┆ f64 ┆ f64 ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │ ╞═════════╪═══════════╪═══════════╪═══════════╪═══╪══════════╪══════════╪══════════╪══════════╡ │ overlap ┆ 39.649682 ┆ 15.127389 ┆ 28.025478 ┆ … ┆ 3.025478 ┆ 2.707006 ┆ 1.592357 ┆ 0.159236 │ │ aRSC ┆ 32.160414 ┆ 28.952135 ┆ 23.05304 ┆ … ┆ 6.080207 ┆ 1.293661 ┆ 2.069858 ┆ 0.07762 │ │ pRSC ┆ 25.947955 ┆ 27.95539 ┆ 27.459727 ┆ … ┆ 3.122677 ┆ 2.973978 ┆ 1.982652 ┆ 1.016109 │ └─────────┴───────────┴───────────┴───────────┴───┴──────────┴──────────┴──────────┴──────────┘
- Parameters:
region (str) – region name
unit (Literal['counts', 'fraction']) – value unit. {‘counts’, ‘fraction’}. default is ‘fraction’
source_order (tuple[str, ...] | None) – source order in dataframe (rows)
show_col (str | None) – force set show col to which level. use case: if a low level area name is classified and show in high level (i.e., TH).
animal (str | None) – with animal column as subregion dataframe
- Returns:
- Return type:
- clear(n=5)
See polars.DataFrame.clear.
- Parameters:
n (int)
- Return type:
Self
- clone()
Clone the wrapper.
- Return type:
Self
- property columns: list[str]
See polars.DataFrame.columns.
- drop(*columns, strict=True)
See polars.DataFrame.drop.
- Parameters:
columns (pty.ColumnNameOrSelector | Iterable[pty.ColumnNameOrSelector])
strict (bool)
- Return type:
Self
- drop_nulls(subset)
See polars.DataFrame.drop_nulls.
- Parameters:
subset (pty.ColumnNameOrSelector | Collection[pty.ColumnNameOrSelector])
- Return type:
Self
- fill_nan(value=None)
See polars.DataFrame.fill_nan.
- Parameters:
value (pl.Expr | int | float | None)
- Return type:
Self
- fill_null(value=None, strategy=None, limit=None, **kwargs)
See polars.DataFrame.fill_null.
- Parameters:
value (Any | pl.Expr | None)
strategy (pty.FillNullStrategy | None)
limit (int | None)
- Return type:
Self
- filter(*predicates, **constraints)
See polars.DataFrame.filter.
- Parameters:
predicates (pty.IntoExprColumn | Iterable[pty.IntoExprColumn] | bool | list[bool] | np.ndarray)
constraints (Any)
- Return type:
Self
- group_by(*by, maintain_order=False, **named_by)
See polars.DataFrame.group_by.
- Parameters:
by (pty.IntoExpr | Iterable[pty.IntoExpr])
maintain_order (bool)
named_by (pty.IntoExpr)
- Return type:
GroupBy
- head(n=5)
See polars.DataFrame.head.
- Parameters:
n (int)
- Return type:
Self
- join(other, on, *args, **kwargs)
See polars.DataFrame.join.
- Parameters:
other (pl.DataFrame | DataFrameWrapper)
- Return type:
Self
- lazy()
Wrap dataframe in a lazy wrapper.
- Return type:
LazyDataFrameWrapper[Self]
- limit(n=5)
See polars.DataFrame.limit.
- Parameters:
n (int)
- Return type:
Self
- partition_by(by, *more_by, as_dict=False, **kwargs)
See polars.DataFrame.partition_by.
- pipe(function, *args, **kwargs)
See polars.DataFrame.pipe.
- Parameters:
function (Callable[Concatenate[pl.DataFrame, P], pl.DataFrame])
args (P.args)
kwargs (P.kwargs)
- Return type:
Self
- rename(mapping)
See polars.DataFrame.rename.
- Parameters:
mapping (dict[str, str] | Callable[[str], str])
- Return type:
Self
- property schema: Schema
See polars.DataFrame.schema.
- select(*exprs, **named_exprs)
See polars.DataFrame.select.
- Parameters:
exprs (pty.IntoExpr | Iterable[pty.IntoExpr])
named_exprs (pty.IntoExpr)
- Return type:
Self
- slice(offset, length=None)
See polars.DataFrame.slice.
- Parameters:
offset (int)
length (int | None)
- Return type:
Self
- sort(by, *more_by, **kwargs)
See polars.DataFrame.sort.
- Return type:
Self
- tail(n=5)
See polars.DataFrame.tail.
- Parameters:
n (int)
- Return type:
Self
- with_columns(*exprs, **named_exprs)
See polars.DataFrame.with_columns.
- Parameters:
exprs (pty.IntoExpr | Iterable[pty.IntoExpr])
named_exprs (pty.IntoExpr)
- Return type:
Self
- with_row_index(name='index', offset=0)
See polars.DataFrame.with_row_index.
- Parameters:
name (str)
offset (int)
- Return type:
Self