BaderLab / Tempora

Pathway-based trajectory inference method for time-series scRNAseq data
MIT License
25 stars 6 forks source link

Hi, I am getting now a new error when trying to plot trajectory #6

Closed nmalwinka closed 4 years ago

nmalwinka commented 4 years ago

The error I am getting is:

tempora_obj <- PlotTrajectory(tempora_obj)
Error in igraph::graph_from_data_frame(d = object@trajectory, vertices = object@cluster.metadata,  : 
  Some vertex names in edge list are not listed in vertex data frame

The tempora object looks like:

> tempora_obj@cluster.metadata
   Id          T.0         T.1         T.4         T.24         T.36         T.48 Cluster_time_score         label
1   2 0.7266018115 0.243710164 0.028178464 0.0006709158 0.0006709158 0.0001677290           1.305602   Cluster 1-2
2   1 0.0523737118 0.173171144 0.696063524 0.0016894746 0.0217942220 0.0549079236           2.932083   Cluster 2-1
3  12 0.0099567100 0.045887446 0.854978355 0.0021645022 0.0090909091 0.0779220779           3.188312  Cluster 3-12
4  14 0.6438356164 0.268368618 0.080323786 0.0000000000 0.0068493151 0.0006226650           1.459527  Cluster 4-14
5   5 0.1443736730 0.756687898 0.045010616 0.0042462845 0.0492569002 0.0004246285           2.058599   Cluster 5-5
6   8 0.1607050285 0.836702955 0.000000000 0.0010368066 0.0000000000 0.0015552100           1.847589   Cluster 6-8
7  23 0.2727272727 0.672727273 0.054545455 0.0000000000 0.0000000000 0.0000000000           1.781818  Cluster 7-23
8  21 0.3903133903 0.481481481 0.071225071 0.0170940171 0.0199430199 0.0199430199           1.854701  Cluster 8-21
9   3 0.0668740280 0.004276827 0.003888025 0.0139968896 0.3600311042 0.5509331260           5.248834   Cluster 9-3
10 20 0.1876923077 0.295384615 0.344615385 0.0292307692 0.0738461538 0.0692307692           2.713846 Cluster 10-20
11 16 0.0141732283 0.031496063 0.000000000 0.9102362205 0.0283464567 0.0157480315           3.954331 Cluster 11-16
12 22 0.1277533040 0.026431718 0.013215859 0.2555066079 0.4405286344 0.1365638767           4.264317 Cluster 12-22
13  9 0.0135350318 0.003184713 0.019904459 0.9554140127 0.0039808917 0.0039808917           3.945064  Cluster 13-9
14 10 0.0184049080 0.011247444 0.009202454 0.1901840491 0.4222903885 0.3486707566           5.032720 Cluster 14-10
15 17 0.0150501672 0.003344482 0.025083612 0.9498327759 0.0050167224 0.0016722408           3.931438 Cluster 15-17
16 13 0.0106524634 0.006657790 0.007989348 0.6245006658 0.1318242344 0.2183754993           4.515313 Cluster 16-13
17  7 0.0006345178 0.000000000 0.001269036 0.1008883249 0.3020304569 0.5951776650           5.489213  Cluster 17-7
18  0 0.0067313713 0.012210394 0.012366938 0.0419536631 0.5391358798 0.3876017533           5.257358  Cluster 18-0
19 11 0.0040816327 0.006122449 0.039795918 0.1479591837 0.2897959184 0.5122448980           5.250000 Cluster 19-11
20  6 0.0069726903 0.006391633 0.006972690 0.1929110982 0.4962231261 0.2905287623           5.036607  Cluster 20-6
21 19 0.0143198091 0.021479714 0.014319809 0.9140811456 0.0167064439 0.0190930788           3.954654 Cluster 21-19
22  4 0.0133333333 0.005079365 0.008253968 0.9669841270 0.0044444444 0.0019047619           3.949841  Cluster 22-4
23 18 0.0375000000 0.016071429 0.019642857 0.8339285714 0.0375000000 0.0553571429           3.983929 Cluster 23-18
24 15 0.0111642743 0.017543860 0.031897927 0.9122807018 0.0111642743 0.0159489633           3.942584 Cluster 24-15
> tempora_obj@trajectory
   from to from_clusterscore to_clusterscore      direction type
1     1  5          1.305602        2.058599 unidirectional    1
3     1 12          1.305602        4.264317 unidirectional    1
5     1 23          1.305602        3.983929 unidirectional    1
7     1 24          1.305602        3.942584 unidirectional    1
10    8  2          1.854701        2.932083 unidirectional    1
11    2 14          2.932083        5.032720 unidirectional    1
13    2 23          2.932083        3.983929 unidirectional    1
16    6  3          1.847589        3.188312 unidirectional    1
18   10  3          2.713846        3.188312 unidirectional    1
19    3 11          3.188312        3.954331 unidirectional    1
21    4 13          1.459527        3.945064 unidirectional    1
23    4 15          1.459527        3.931438 unidirectional    1
25    4 18          1.459527        5.257358 unidirectional    1
28    8  5          1.854701        2.058599 unidirectional    1
29    5 14          2.058599        5.032720 unidirectional    1
31    6 18          1.847589        5.257358 unidirectional    1
33    6 20          1.847589        5.036607 unidirectional    1
35    6 22          1.847589        3.949841 unidirectional    1
37    7 10          1.781818        2.713846 unidirectional    1
39    7 18          1.781818        5.257358 unidirectional    1
41    7 19          1.781818        5.250000 unidirectional    1
43    7 23          1.781818        3.983929 unidirectional    1
46   13  9          3.945064        5.248834 unidirectional    1
48   15  9          3.931438        5.248834 unidirectional    1
49    9 17          5.248834        5.489213 unidirectional    1
51   12 14          4.264317        5.032720 unidirectional    1
53   16 17          4.515313        5.489213 unidirectional    1
56   20 19          5.036607        5.250000 unidirectional    1
57   21 23          3.954654        3.983929  bidirectional    3

Any idea what happened? Thank you.

thinh-tran commented 4 years ago

Hi! This is a bug with Seurat cluster names, which start at 0 instead of 1. I've merged a fix to the main branch that should fix this problem. If you don't want to run everything again, an easy temporary fix can be to shift the vertex ID in the cluster.metadata dataframe by 1 so it matches up with the trajectory dataframe: tempora_obj@cluster.metadata$Id <- tempora_obj@cluster.metadata$Id + 1