neuralib.atlas.ccf.dataframe.RoiNormalizedDataFrame

class neuralib.atlas.ccf.dataframe.RoiNormalizedDataFrame[source]

Bases: DataFrameWrapper

RoiNormalizedDataFrame with each area per row (unique source, hemisphere)

  • Required fields:
    • counts: roi counts

    • fraction: roi fraction for individual sources (aka. per channel(source) normalized)

    • hemisphere: which hemisphere

    • area column field {‘acronym’, ‘tree_0’, ‘tree_1’, ‘tree_2’, ‘tree_3’, ‘tree_4’}

  • Optional field:
    • normalization-specific fields (if not ‘none’): normalized, Volumes [mm^3], volume_mm3, n_neurons

__init__(df, classified_column, normalized)[source]
Parameters:
  • df (DataFrame) – DataFrame with required fields

  • classified_column (str) – classified column for the brain area

  • normalized (Literal['channel', 'volume', 'cell', 'none']) – ROIS_NORM_TYPE

Methods

__init__(df, classified_column, normalized)

clear([n])

See polars.DataFrame.clear.

clone()

Clone the wrapper.

dataframe([dataframe, may_inplace])

RoiNormalizedDataFrame (Volume normalized as example) .

drop(*columns[, strict])

See polars.DataFrame.drop.

drop_nulls(subset)

See polars.DataFrame.drop_nulls.

fill_nan([value])

See polars.DataFrame.fill_nan.

fill_null([value, strategy, limit])

See polars.DataFrame.fill_null.

filter(*predicates, **constraints)

See polars.DataFrame.filter.

filter_areas(areas)

filter the dataframe with specified areas

filter_sources(source)

filter the dataframe with specified sources

group_by(*by[, maintain_order])

See polars.DataFrame.group_by.

head([n])

See polars.DataFrame.head.

join(other, on[, how, left_on, right_on, ...])

See polars.DataFrame.join.

lazy()

Wrap dataframe in a lazy wrapper.

limit([n])

See polars.DataFrame.limit.

partition_by(by, *more_by[, as_dict])

See polars.DataFrame.partition_by.

pipe(function, *args, **kwargs)

See polars.DataFrame.pipe.

rename(mapping)

See polars.DataFrame.rename.

select(*exprs, **named_exprs)

See polars.DataFrame.select.

slice(offset[, length])

See polars.DataFrame.slice.

sort(by, *more_by[, descending, nulls_last, ...])

See polars.DataFrame.sort.

tail([n])

See polars.DataFrame.tail.

to_bias_index(source_a, source_b)

Bias Index dataframe used to determine bias within two sources (positive value toward source a and negative value toward source b) .

to_winner(sources)

Winner dataframe used for plotting (i.e., ternary plot) .

with_animal_column(animal)

with animal id column

with_cell_density_column()

Normalized to number of neurons foreach brain region (based on CellAtlas data source)

with_columns(*exprs, **named_exprs)

See polars.DataFrame.with_columns.

with_density_column([backend])

with_row_index([name, offset])

See polars.DataFrame.with_row_index.

Attributes

classified_column

region classified column name

columns

See polars.DataFrame.columns.

normalized

normalization type

normalized_unit

unit based on the normalized

schema

See polars.DataFrame.schema.

value_column

value column based on the normalized

__init__(df, classified_column, normalized)[source]
Parameters:
  • df (DataFrame) – DataFrame with required fields

  • classified_column (str) – classified column for the brain area

  • normalized (Literal['channel', 'volume', 'cell', 'none']) – ROIS_NORM_TYPE

property classified_column: str

region classified column name

property normalized: Literal['channel', 'volume', 'cell', 'none']

normalization type

property value_column: str

value column based on the normalized

property normalized_unit: str

unit based on the normalized

dataframe(dataframe=None, may_inplace=True)[source]

RoiNormalizedDataFrame (Volume normalized as example)

┌─────────┬────────┬────────┬───────────┬────────────┬────────────────┬────────────┐
│ 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:
  • dataframe (DataFrame | None)

  • may_inplace (bool)

Return type:

DataFrame | RoiNormalizedDataFrame

with_density_column(backend='cellatlas')[source]
Parameters:

backend (Literal['cellatlas', 'brainglobe']) – Volume information calculated from which backend. {‘cellatlas’, ‘brainglobe’}

Returns:

Return type:

Self

with_cell_density_column()[source]

Normalized to number of neurons foreach brain region (based on CellAtlas data source)

Return type:

Self

with_animal_column(animal)[source]

with animal id column

Return type:

Self

filter_areas(areas)[source]

filter the dataframe with specified areas

Parameters:

areas (str | list[str])

Return type:

Self

filter_sources(source)[source]

filter the dataframe with specified sources

Parameters:

source (str | list[str])

Return type:

Self

to_bias_index(source_a, source_b)[source]

Bias Index dataframe used to determine bias within two sources (positive value toward source a and negative value toward source b)

┌────────┬────────────┐
│ tree_2 ┆ bias_index │
│ ---    ┆ ---        │
│ str    ┆ f64        │
╞════════╪════════════╡
│ ATN    ┆ -1.192889  │
│ VIS    ┆ -1.145786  │
│ CLA    ┆ -0.86059   │
│ SUB    ┆ -0.478069  │
│ STRd   ┆ -0.463589  │
│ …      ┆ …          │
│ ENT    ┆ 0.580593   │
│ AUD    ┆ 0.610688   │
│ PTLp   ┆ 1.292926   │
│ MO     ┆ 1.945567   │
│ SS     ┆ 2.163074   │
└────────┴────────────┘
Parameters:
  • source_a (str) – source a string

  • source_b (str) – source b string

Returns:

Return type:

DataFrame

to_winner(sources)[source]

Winner dataframe used for plotting (i.e., ternary plot)

┌────────┬─────────┬──────┬──────┬───────┬────────┐
│ tree_2 ┆ overlap ┆ pRSC ┆ aRSC ┆ total ┆ winner │
│ ---    ┆ ---     ┆ ---  ┆ ---  ┆ ---   ┆ ---    │
│ str    ┆ u32     ┆ u32  ┆ u32  ┆ u32   ┆ str    │
╞════════╪═════════╪══════╪══════╪═══════╪════════╡
│ ACA    ┆ 1208    ┆ 3296 ┆ 5761 ┆ 9057  ┆ aRSC   │
│ VIS    ┆ 628     ┆ 4035 ┆ 3865 ┆ 7900  ┆ pRSC   │
│ MO     ┆ 460     ┆ 714  ┆ 5829 ┆ 6543  ┆ aRSC   │
│ …      ┆ …       ┆ …    ┆ …    ┆ …     ┆ …      │
│ AUD    ┆ 44      ┆ 165  ┆ 534  ┆ 699   ┆ aRSC   │
│ TEa    ┆ 34      ┆ 206  ┆ 358  ┆ 564   ┆ aRSC   │
└────────┴─────────┴──────┴──────┴───────┴────────┘
Parameters:

sources (Sequence[str]) – source sequences for calculating the total. The above case should be specified as [‘aRSC’, ‘pRSC’]

Returns:

Winner dataframe

Return type:

DataFrame