LouisFaure / scFates

a scalable python suite for tree inference and advanced pseudotime analysis from scRNAseq data.
https://scfates.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
50 stars 2 forks source link

3 milesones make error in scf.tl.linearity_deviation. #37

Open ChaewonKim99 opened 2 days ago

ChaewonKim99 commented 2 days ago

To begin with, Thank you for creating such an excellent tool. However, an error occurs in the default code when there are three milestones. Do you have any idea how to resolve this issue?

I use sc.pl.pca(adata,color="milestones",size = 3)

다운로드

scf.tl.rename_milestones(adata,new={"0":"Disease","2":"Normal"})

scf.tl.linearity_deviation(adata, start_milestone="Normal", end_milestone="Disease", n_jobs=20, plot=True, basis="pca")


AttributeError Traceback (most recent call last) Cell In[41], line 1 ----> 1 scf.tl.linearity_deviation(adata, 2 start_milestone="Disease", 3 end_milestone="Normal", 4 n_jobs=20, plot=True, basis="pca")

File ~/.local/lib/python3.9/site-packages/scFates/tools/linearity_deviation.py:151, in linearity_deviation(adata, start_milestone, end_milestone, percentiles, n_jobs, n_map, plot, basis, copy) 148 n_jobs_map = n_jobs 149 n_jobs = 1 --> 151 rss = ProgressParallel( 152 total=n_map, 153 n_jobs=n_jobs_map, 154 use_tqdm=n_map > 1, 155 desc=" multi mapping", 156 file=sys.stdout, 157 )(delayed(lindev_map)(m) for m in range(n_map)) 159 if plot: 160 import scanpy as sc

File ~/.local/lib/python3.9/site-packages/scFates/tools/utils.py:47, in ProgressParallel.call(self, *args, kwargs) 40 def call(self, *args, *kwargs): 41 with tqdm( 42 disable=not self._use_tqdm, 43 total=self._total, 44 desc=self._desc, 45 file=self._file, 46 ) as self._pbar: ---> 47 return Parallel.call(self, args, kwargs)

File /opt/anaconda/envs/velocities/lib/python3.9/site-packages/joblib/parallel.py:1863, in Parallel.call(self, iterable) 1861 output = self._get_sequential_output(iterable) 1862 next(output) -> 1863 return output if self.return_generator else list(output) 1865 # Let's create an ID that uniquely identifies the current call. If the 1866 # call is interrupted early and that the same instance is immediately 1867 # re-used, this id will be used to prevent workers that were 1868 # concurrently finalizing a task from the previous call to run the 1869 # callback. 1870 with self._lock:

File /opt/anaconda/envs/velocities/lib/python3.9/site-packages/joblib/parallel.py:1792, in Parallel._get_sequential_output(self, iterable) 1790 self.n_dispatched_batches += 1 1791 self.n_dispatched_tasks += 1 -> 1792 res = func(*args, **kwargs) 1793 self.n_completed_tasks += 1 1794 self.print_progress()

File ~/.local/lib/python3.9/site-packages/scFates/tools/linearity_deviation.py:94, in linearity_deviation..lindev_map(m) 83 img.add_edges(edges) 85 cells = getpath( 86 img, 87 graph["milestones"][start_milestone], (...) 91 df, 92 ) ---> 94 t_perc = [cells.t.quantile(p / 100) for p in percentiles] 96 df[name + "_lindev_sel"] = np.nan 97 df.loc[ 98 adata.obs_names.isin(cells.index), name + "_lindev_sel" 99 ] = "putative bridge"

File ~/.local/lib/python3.9/site-packages/scFates/tools/linearity_deviation.py:94, in (.0) 83 img.add_edges(edges) 85 cells = getpath( 86 img, 87 graph["milestones"][start_milestone], (...) 91 df, 92 ) ---> 94 t_perc = [cells.t.quantile(p / 100) for p in percentiles] 96 df[name + "_lindev_sel"] = np.nan 97 df.loc[ 98 adata.obs_names.isin(cells.index), name + "_lindev_sel" 99 ] = "putative bridge"

AttributeError: 'NoneType' object has no attribute 't'

ChaewonKim99 commented 1 day ago

I use this code.
adata.uns["graph"]["milestones"] = {"Disease":0,"Normal":2, "Normal": 6} and the result is it. there is NA image