[docs]defrun_ica(adata:AnnData,n_factors:int=20,fun:str="logcosh",tol:float=0.0001,use_data:str|None=None,copy:bool=False,)->AnnData|None:"""\ FastICA: a fast algorithm for Independent Component Analysis. Parameters ---------- adata Annotated data matrix. n_factors Number of components to use. If none is passed, all are used. fun The functional form of the G function used in the approximation to neg-entropy. Could be either 'logcosh', 'exp', or 'cube'. You can also provide your own function. It should return a tuple containing the value of the function, and of its derivative, in the point. Example:: def my_g(x): return x ** 3, (3 * x ** 2).mean(axis=-1) tol Tolerance on update at each iteration. use_data if None, then using all the gene expression profile. Else, use the chosen data from adata.obsm. copy Return a copy instead of writing to adata. Returns ------- Depending on `copy`, returns or updates `adata` with the following fields. `X_ica` : :class:`numpy.ndarray` (`adata.obsm`) """adata=adata.copy()ifcopyelseadataifuse_dataisNone:ifissparse(adata.X):matrix=adata.X.toarray()else:matrix=adata.Xelse:matrix=adata.obsm[use_data].valuesica=FastICA(n_components=n_factors,fun=fun,tol=tol)latent=ica.fit_transform(matrix)adata.obsm["X_ica"]=latentadata.uns["ica"]={"params":{"n_factors":n_factors,"fun":fun,"tol":tol}}print("ICA is done! Generated in adata.obsm['X_ica'] and parameters in "+"adata.uns['ica']")returnadataifcopyelseNone