nbnode.apply package¶
Submodules¶
nbnode.apply.count_celltree_df module¶
- nbnode.apply.count_celltree_df.count_celltree_df(celltree_gated: NBNode) DataFrame[source]¶
Count the number of rows in node.data (per node) grouped by “sample_name” and concat them into a dataframe
- Parameters:
celltree_gated (NBNode) – A gated celltree, e.g. as result from gate_csv()
- Returns:
- pd.DataFrame with
rows: Samples columns: Nodes values: Counts index: Sample identifier
Examples
>>> import os >>> from nbnode.apply.gate_csv import gate_csv >>> rescaled_data_dir = os.path.join( ... "example_data", "asinh.align_manual.CD3_Gate" ... ) >>> if not os.path.exists(rescaled_data_dir): ... raise FileNotFoundError( ... rescaled_data_dir, ... " has not been found, did you run tests/examples/e01_download.sh?", ... ) >>> rescaled_data_dir_files = [ ... os.path.join(rescaled_data_dir, file_x) ... for file_x in os.listdir(rescaled_data_dir) ... ] >>> print(rescaled_data_dir_files) >>> a = gate_csv(csv=rescaled_data_dir_files[0]) >>> b = gate_csv(csv=rescaled_data_dir_files[0:3]) >>> from nbnode.apply.count_celltree import count_celltree_df >>> print(count_celltree_df(a)) >>> print(count_celltree_df(b))
nbnode.apply.gate_csv module¶
- nbnode.apply.gate_csv.gate_csv(csv: str | List[str], celltree='default', new_colnames=['FS', 'FS.0', 'SS', 'CD45RA', 'CCR7', 'CD28', 'PD1', 'CD27', 'CD4', 'CD8', 'CD3', 'CD57', 'CD45'], verbose=True)[source]¶
_summary_
- Parameters:
csv (Union[str, List[str]]) – Path to a single .csv file or a list of .csv files
celltree (str, optional) – _description_. Defaults to “default”.
new_colnames (List[str]) – vector of new colnames for the csvs. Usually used to make the colnames of the csvs matching to the celltree.
verbose (bool, optional) – _description_. Defaults to True.
- Returns:
_description_
- Return type:
_type_
Examples
>>> rescaled_data_dir = os.path.join( ... "example_data", "asinh.align_manual.CD3_Gate") >>> if not os.path.exists(rescaled_data_dir): ... raise FileNotFoundError( ... rescaled_data_dir, ... " has not been found, did you run tests/examples/e01_download.sh?", ... ) >>> rescaled_data_dir_files = [os.path.join(rescaled_data_dir, file_x) ... for file_x in os.listdir(rescaled_data_dir)] >>> print(rescaled_data_dir_files) >>> gate_csv(csv=rescaled_data_dir_files[0]) >>> gate_csv(csv=rescaled_data_dir_files[0:3])