Manipulation#

set_obs_names

Sets a column as the new first column of obs, i.e. the obs_names.

set_var_names

Sets a column as the new first column of var, i.e. the var_names.

set_num_threads

Return a new Pseudobulk dataset with a different default number of threads.

filter_obs

Equivalent to df.filter() from polars, but applied to both obs and X for each cell type.

filter_var

Equivalent to df.filter() from polars, but applied to both var and X for each cell type.

select_obs

Equivalent to df.select() from polars, but applied to each cell type's obs.

select_var

Equivalent to df.select() from polars, but applied to each cell type's var.

select_cell_types

Create a new Pseudobulk dataset subset to the cell type(s) in cell_types and more_cell_types.

with_columns_obs

Equivalent to df.with_columns() from polars, but applied to each cell type's obs.

with_columns_var

Equivalent to df.with_columns() rom polars, but applied to each cell type's var.

drop_obs

Create a new Pseudobulk dataset with columns and more_columns removed from obs.

drop_var

Create a new Pseudobulk dataset with columns and more_columns removed from var.

drop_cell_types

Create a new Pseudobulk dataset with cell_types and more_cell_types removed.

rename_obs

Create a new Pseudobulk dataset with column(s) of obs renamed for each cell type.

rename_var

Create a new Pseudobulk dataset with column(s) of var renamed for each cell type.

rename_cell_types

Create a new Pseudobulk dataset with cell type(s) renamed.

cast_X

Cast each cell type's X to the specified data type.

cast_obs

Cast column(s) of each cell type's obs to the specified data type(s).

cast_var

Cast column(s) of each cell type's var to the specified data type(s).

join_obs

Left-join each cell type's obs with another DataFrame, using the same logic as df.join().

join_var

Left-join each cell type's var with another DataFrame, using the same logic as df.join().

subsample_obs

Subsample a specific number or fraction of samples.

subsample_var

Subsample a specific number or fraction of genes.

split_by_cell_type

Split this Pseudobulk dataset into a tuple of Pseudobulk datasets with one cell type each.

concat_obs

Concatenate one or more other Pseudobulk datasets with this one, sample-wise.

concat_var

Concatenate one or more other Pseudobulk datasets with this one, gene-wise.

copy

Make a copy of this Pseudobulk dataset.

to_df

Convert this Pseudobulk object to a polars DataFrame, with one row per (sample, cell type) pair and one column per gene.

map_X

Apply a function to each cell type's X.

map_obs

Apply a function to each cell type's obs.

map_var

Apply a function to each cell type's var.

pipe

Apply a function to a Pseudobulk dataset.

pipe_X

Apply a function to a Pseudobulk dataset's X.

pipe_obs

Apply a function to a Pseudobulk dataset's obs.

pipe_var

Apply a function to a Pseudobulk dataset's var.