celloracle.utility module

The utility module has several functions that support celloracle.

celloracle.utility.exec_process(commands, message=True, wait_finished=True, return_process=True)

Excute a command. This is a wrapper of “subprocess.Popen”

Parameters
  • commands (str) – command.

  • message (bool) – Whether to return a message or not.

  • wait_finished (bool) – Whether or not to wait for the process to finish. If false, the process will be perfomed in background and the function will finish immediately

  • return_process (bool) – Whether to return “process”.

celloracle.utility.intersect(list1, list2)

Intersect two list and get components that exists in both list.

Parameters
  • list1 (list) – input list.

  • list2 (list) – input list.

Returns

intersected list.

Return type

list

celloracle.utility.knn_data_transferer(adata_ref, adata_que, n_neighbors=20, cluster_name=None, embedding_name=None, adata_true=None, transfer_color=True, n_PCA=30, use_PCA_in_adata=False, meta_data=None)

Extract categorical information from adata.obs or embedding information from adata.obsm and transfer these information into query anndata. In the calculation, KNN is used after PCA.

Parameters
  • adata_ref (anndata) – reference anndata

  • adata_que (anndata) – query anndata

  • cluster_name (str or list of str) – cluster name(s) to be transfered. If you want to transfer multiple data, you can set the cluster names as a list.

  • embedding_name (str or list of str) – embedding name(s) to be transfered. If you want to transfer multiple data, you can set the embedding names as a list.

  • adata_true (str) – This argument can be used for the validataion of this algorithm. If you have true answer, you can set it. If you set true answer, the function will return some metrics for benchmarking.

  • transfer_color (bool) – Whether or not to transfer color data in addition to cluster information.

  • n_PCA (int) – Number of PCs that will be used for the input of KNN algorithm.

celloracle.utility.load_hdf5(file_path, object_class_name=None)

Load an object of celloracle’s custom class that was saved as hdf5.

Parameters
  • file_path (str) – file_path.

  • object_class_name (str) – Types of object. If it is None, object class will be identified from the extension of file_name. Default is None.

celloracle.utility.load_pickled_object(filepath)

Load pickled object.

Parameters

filepath (str) – file path.

Returns

loaded object.

Return type

python object

class celloracle.utility.makelog(file_name=None, directory=None)

Bases: object

This is a class for making log.

info(comment)

Add comment into the log file.

Parameters

comment (str) – comment.

celloracle.utility.save_as_pickled_object(obj, filepath)

Save any object using pickle.

Parameters
  • obj (any python object) – python object.

  • filepath (str) – file path.

celloracle.utility.standard(df)

Standardize value.

Parameters

df (padas.dataframe) – dataframe.

Returns

Data after standardization.

Return type

pandas.dataframe

celloracle.utility.transfer_all_colors_between_anndata(adata_ref, adata_que)

Extract all color information from reference anndata and transfer the color into query anndata.

Parameters
  • adata_ref (anndata) – reference anndata

  • adata_que (anndata) – query anndata

celloracle.utility.transfer_color_between_anndata(adata_ref, adata_que, cluster_name)

Extract color information from reference anndata and transfer the color into query anndata.

Parameters
  • adata_ref (anndata) – reference anndata

  • adata_que (anndata) – query anndata

  • cluster_name (str) – cluster name. This information should exist in the anndata.obs.

celloracle.utility.update_adata(adata)