cellrouter icon indicating copy to clipboard operation
cellrouter copied to clipboard

Using seurat for cellrouter trajectory analysis

Open fereshtehizadi opened this issue 5 years ago • 102 comments

Hi,

I have already my cell clustered by seurat, now I want to use cell router for trajectory analysis? how that would be please? saying cellrouter@sampTab will help but I don't know how to use that for using my seurat clusters here

Thanks a lot for any help

fereshtehizadi avatar Jul 31 '18 11:07 fereshtehizadi

Thanks for using CellRouter! This is very easy with CellRouter. You can use the addInfo function to include n cellrouter@sampTab your seurat clusters and then use the corresponding column for downstream analysis. For example, in the cellrouter tutourial at https://github.com/edroaldo/cellrouter/blob/master/Myeloid_Progenitors/CellRouter_Paul_Tutorial.md :

cellrouter <- addInfo(cellrouter, metadata = samples, colname = 'celltype', metadata.column='cell_type')

You could replace the line above by:

metadata <- [email protected] cellrouter <- addInfo(cellrouter, metadata = metadata, colname = ' seuratClusters', metadata.column='res.0.6') #change res.0.6 for your case

Where res.0.6 is a column in the seurat metadata table with your cluster assignments. This is usually res.0.X depending on how you chose the parameter resolution in the Seurat's function FindClusters.

Then, we can use your Seurat clusters by simplying specyfing the *seuratClusters *column in your the cellrouter analysis, which will consist to replace "population" by "seuratClusters" in the CellRouter functions. For example (for visualization):

plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "seuratClusters", annotation.color = 'seuratClusters_color', showlabels = TRUE, 4.5, 3.5, filename='results/tsne_seurat_clusters.pdf')

and for trajectory analysis, you can do: cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'seuratClusters', num.pcs = 20, sim.type = 'jaccard') plotKNN(cellrouter, reduction.type = 'tsne', column.ann = 'seuratClusters', column.color = 'seuratClusters_color', width = 5, height = 4, filename='results/knn_tsne_original_clusters.pdf') cellrouter <- findPaths(cellrouter, column='seuratClusters', libdir, paste(getwd(), 'results/paths', sep='/'), method="graph")

As a rule of thumb, in the cellrouter tutorial above, simply replace "population" in the relevant functions by "seuratClusters" and the trajectory identification steps will use your seurat clusters for all downstream analysis.

I will be travelling in the next coulple of days so might be a little bit slower to reply but please let me know how it goes!

Thanks a lot!

2018-07-31 7:40 GMT-04:00 fereshtehizadi [email protected]:

Hi,

I have already my cell clustered by seurat, now I want to use cell router for trajectory analysis? how that would be please? saying cellrouter@sampTab will help but I don't know how to use that for using my seurat clusters here

Thanks a lot for any help

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR1w1qBRjNAZE3AFiNdlgQkLNJ75Qks5uMEIkgaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 12:07 edroaldo

Excuse me I tried these

> cellrouter <- addInfo(cellrouter, metadata = metadata, colname = 'res.0.7')
 Show Traceback
 
 Rerun with Debug
 Error in `*tmp*`[[jj]] : subscript out of bounds In addition: Warning message:
In length(x[[j]]) <- nrows : length of NULL cannot be changed
> cellrouter <- addInfo(cellrouter, metadata = metadata, colname = res.0.7)
 Show Traceback
 
 Rerun with Debug
 Error in `[<-.data.frame`(`*tmp*`, rownames(metadata), colname, value = NULL) : 
  object 'res.0.7' not found > View(metadata)
> View(metadata)
> View(metadata)
> cellrouter <- addInfo(cellrouter, metadata = metadata, colname = 'res.0.7', metadata.column='res.0.7')
Error in rep(colors, times = replicate_row) : invalid 'times' argument
> cellrouter <- addInfo(cellrouter, metadata = metadata, metadata.column='res.0.7')
 Show Traceback
 
 Rerun with Debug
 Error in (function(x, i, exact) if (is.matrix(i)) as.matrix(x)[[i]] else .subset2(x,  : 
  argument "colname" is missing, with no default In addition: Warning messages:
1: In `[<-.factor`(`*tmp*`, iseq, value = c("0", "0", "0", "1", "1",  :
  invalid factor level, NA generated
2: In `[<-.factor`(`*tmp*`, iseq, value = c("0", "0", "0", "1", "1",  :
  invalid factor level, NA generated
> 
> cellrouter <- addInfo(cellrouter, colname = res.0.7, metadata.column = res.0.7)
Error in addInfo(cellrouter, colname = res.0.7, metadata.column = res.0.7) : 
  argument "metadata" is missing, with no default
> cellrouter <- addInfo(cellrouter, metadata=metadata, colname = res.0.7, metadata.column = res.0.7)
 Show Traceback
 
 Rerun with Debug
 Error in (function(x, i, exact) if (is.matrix(i)) as.matrix(x)[[i]] else .subset2(x,  : 
  object 'res.0.7' not found > cellrouter <- addInfo(cellrouter, metadata=metadata, colname = "res.0.7", metadata.column = "res.0.7")
Error in rep(colors, times = replicate_row) : invalid 'times' argument
> cellrouter <- addInfo(cellrouter, metadata=metadata, colname = 'res.0.7', metadata.column = 'res.0.7')
Error in rep(colors, times = replicate_row) : invalid 'times' argument
> View(metadata)
> 

my seurat metadata has 4 columns nGene, nUMI, orig.ident and res.0.7

fereshtehizadi avatar Jul 31 '18 13:07 fereshtehizadi

You need to make sure that the dimensions of the raw data after creating the cellrouter object and the dimensions of the metadata table from seurat are the same. Please, try something like:

data <- as.data.frame(as.matrix([email protected])) cellrouter <- CellRouter(rawdata=as.data.frame(data), min.cells=0, min.genes=0)

Please follow the steps in the previous email with the addInfo function and let me know how it goes...

Thanks!

2018-07-31 9:38 GMT-04:00 fereshtehizadi [email protected]:

Excuse me I tried these

cellrouter <- addInfo(cellrouter, metadata = metadata, colname = 'res.0.7') Show Traceback

Rerun with Debug Error in *tmp*[[jj]] : subscript out of bounds In addition: Warning message: In length(x[[j]]) <- nrows : length of NULL cannot be changed

cellrouter <- addInfo(cellrouter, metadata = metadata, colname = res.0.7) Show Traceback

Rerun with Debug Error in [<-.data.frame(*tmp*, rownames(metadata), colname, value = NULL) : object 'res.0.7' not found > View(metadata)

View(metadata) View(metadata) cellrouter <- addInfo(cellrouter, metadata = metadata, colname = 'res.0.7', metadata.column='res.0.7') Error in rep(colors, times = replicate_row) : invalid 'times' argument cellrouter <- addInfo(cellrouter, metadata = metadata, metadata.column='res.0.7') Show Traceback

Rerun with Debug Error in (function(x, i, exact) if (is.matrix(i)) as.matrix(x)[[i]] else .subset2(x, : argument "colname" is missing, with no default In addition: Warning messages: 1: In [<-.factor(*tmp*, iseq, value = c("0", "0", "0", "1", "1", : invalid factor level, NA generated 2: In [<-.factor(*tmp*, iseq, value = c("0", "0", "0", "1", "1", : invalid factor level, NA generated

my seurat metadata has 4 columns nGene, nUMI, orig.ident and res.0.7

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409223974, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR38LmtcGmOtLeuUhUR98Jxeq8-bIks5uMF3kgaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 13:07 edroaldo

Excuse me,

> data <- as.data.frame(as.matrix([email protected]))
> cellrouter <- CellRouter(rawdata=as.data.frame(data), min.cells=0,
+ min.genes=0)
[1] "Initializing CellRouter object"

> metadata <- [email protected]
> cellrouter <- addInfo(cellrouter, metadata=metadata, colname = 'res.0.7', metadata.column = 'res.0.7')

> cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'seuratClusters', num.pcs = 20, sim.type = 'jaccard')
 Show Traceback
 
 Rerun with Debug
 Error in order(...) : argument 1 is not a vector > 
> cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'res.0.7', num.pcs = 20, sim.type = 'jaccard')
[1] "building k-nearest neighbors graph"
 Show Traceback
 
 Rerun with Debug
 Error in dist(matrix) : 
  Can only handle data frames, vectors, matrices, and lists! > 

fereshtehizadi avatar Jul 31 '18 13:07 fereshtehizadi

You have to do either:

cellrouter <- addInfo(cellrouter, metadata=metadata, colname = 'res.0.7', metadata.column = 'res.0.7') or

cellrouter <- addInfo(cellrouter, metadata=metadata, colname = 'seuratClusters', metadata.column = 'res.0.7')

and

cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'res.0.7', num.pcs = 20, sim.type = 'jaccard')

cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'seuratClusters', num.pcs = 20, sim.type = 'jaccard')

column.ann need to match!

Let me know if it works!

Thanks!

2018-07-31 9:50 GMT-04:00 fereshtehizadi [email protected]:

Excuse me,

data <- as.data.frame(as.matrix([email protected])) cellrouter <- CellRouter(rawdata=as.data.frame(data), min.cells=0,

  • min.genes=0) [1] "Initializing CellRouter object"

metadata <- [email protected] cellrouter <- addInfo(cellrouter, metadata=metadata, colname = 'res.0.7', metadata.column = 'res.0.7')

cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'seuratClusters', num.pcs = 20, sim.type = 'jaccard') Show Traceback

Rerun with Debug Error in order(...) : argument 1 is not a vector >

cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'res.0.7', num.pcs = 20, sim.type = 'jaccard') [1] "building k-nearest neighbors graph" Show Traceback

Rerun with Debug Error in dist(matrix) : Can only handle data frames, vectors, matrices, and lists! >

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409227963, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqURwf2TDLUM8BbilUPYXISES5qvtM2ks5uMGDAgaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 13:07 edroaldo

Sorry,


> 
> cellrouter <- addInfo(cellrouter, metadata=metadata, colname ='res.0.7', metadata.column = 'res.0.7') 
> cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'res.0.7',num.pcs = 20, sim.type = 'jaccard')
[1] "building k-nearest neighbors graph"
 Show Traceback
 
 Rerun with Debug
 Error in dist(matrix) : 
  Can only handle data frames, vectors, matrices, and lists! 

fereshtehizadi avatar Jul 31 '18 13:07 fereshtehizadi

Can you please try like this:

cellrouter <- addInfo(cellrouter, metadata=metadata, colname = 'seuratClusters', metadata.column = 'res.0.7')

cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'seuratClusters', num.pcs = 20, sim.type = 'jaccard')

please, send me:

class(cellrouter@ndata)

cellrouter@sampTab[1:5,]

I need to debug a little bit...

I have not seen this error message in this context before...

Thanks!

2018-07-31 9:57 GMT-04:00 fereshtehizadi [email protected]:

Sorry,

cellrouter <- addInfo(cellrouter, metadata=metadata, colname ='res.0.7', metadata.column = 'res.0.7') cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'res.0.7',num.pcs = 20, sim.type = 'jaccard') [1] "building k-nearest neighbors graph" Show Traceback

Rerun with Debug Error in dist(matrix) : Can only handle data frames, vectors, matrices, and lists!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409230308, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR9JJccueHsYZlDRxUlY3y-vDpXR-ks5uMGJbgaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 14:07 edroaldo

Also, were you able to reproduce the tutorial with no errors? I am just checking if that could be some package missing on your side...

thanks!

2018-07-31 10:08 GMT-04:00 Edroaldo Lummertz da Rocha [email protected]:

Can you please try like this:

cellrouter <- addInfo(cellrouter, metadata=metadata, colname = 'seuratClusters', metadata.column = 'res.0.7')

cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'seuratClusters', num.pcs = 20, sim.type = 'jaccard')

please, send me:

class(cellrouter@ndata)

cellrouter@sampTab[1:5,]

I need to debug a little bit...

I have not seen this error message in this context before...

Thanks!

2018-07-31 9:57 GMT-04:00 fereshtehizadi [email protected]:

Sorry,

cellrouter <- addInfo(cellrouter, metadata=metadata, colname ='res.0.7', metadata.column = 'res.0.7') cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'res.0.7',num.pcs = 20, sim.type = 'jaccard') [1] "building k-nearest neighbors graph" Show Traceback

Rerun with Debug Error in dist(matrix) : Can only handle data frames, vectors, matrices, and lists!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409230308, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR9JJccueHsYZlDRxUlY3y-vDpXR-ks5uMGJbgaJpZM4VoF6T .

-- Edroaldo

-- Edroaldo

edroaldo avatar Jul 31 '18 14:07 edroaldo

Sorry , I have never been able to trace the tutorial without stopping by error that is why I am disturbing you

> cellrouter <- addInfo(cellrouter, metadata=metadata, colname ='seuratClusters', metadata.column = 'res.0.7')
> cellrouter <- buildKNN(cellrouter, k = 10, column.ann ='seuratClusters', num.pcs = 20, sim.type = 'jaccard')
[1] "building k-nearest neighbors graph"
 Show Traceback
 
 Rerun with Debug
 Error in dist(matrix) : 
  Can only handle data frames, vectors, matrices, and lists! 
> class(cellrouter@ndata)
[1] "data.frame"
> cellrouter@sampTab[1:5,]
     sample_id nGene    nUMI conditions res.0.7 res.0.7_color seuratClusters seuratClusters_color
s1.1      s1.1  4324  373695       s1.1       0       #FF7F00              0              #FF7F00
s1.2      s1.2  5595 1074542       s1.2       0       #FF7F00              0              #FF7F00
s1.3      s1.3  2061   49534       s1.3       0       #FF7F00              0              #FF7F00
s1.4      s1.4  4672  772376       s1.4       1       #FF7F00              1              #FF7F00
s1.5      s1.5  3873  272283       s1.5       1       #FF7F00              1              #FF7F00
> 

fereshtehizadi avatar Jul 31 '18 14:07 fereshtehizadi

No problem.

Can you please check if you have the following packages: library('cccd') library('proxy')

I think this might be missing in your R installation. You can install this using:

source('https://bioconductor.org/biocLite.R') biocLite('cccd') biocLite('proxy')

I will include a more informative error message in the next release of CellRouter. Thanks for helping with that! Let me know if that works!

2018-07-31 10:12 GMT-04:00 fereshtehizadi [email protected]:

Sorry , I have never been able to trace the tutorial without stopping by error that is why I am disturbing you

cellrouter <- buildKNN(cellrouter, k = 10, column.ann ='seuratClusters', num.pcs = 20, sim.type = 'jaccard') [1] "building k-nearest neighbors graph" Show Traceback

Rerun with Debug Error in dist(matrix) : Can only handle data frames, vectors, matrices, and lists! > class(cellrouter@ndata) [1] "data.frame"

cellrouter@sampTab[1:5,] sample_id nGene nUMI conditions res.0.7 res.0.7_color seuratClusters seuratClusters_color s1.1 s1.1 4324 373695 s1.1 0 #FF7F00 0 #FF7F00 s1.2 s1.2 5595 1074542 s1.2 0 #FF7F00 0 #FF7F00 s1.3 s1.3 2061 49534 s1.3 0 #FF7F00 0 #FF7F00 s1.4 s1.4 4672 772376 s1.4 1 #FF7F00 1 #FF7F00 s1.5 s1.5 3873 272283 s1.5 1 #FF7F00 1 #FF7F00

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409235115, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqURw1A1KriEeI2tW-IjuHRowfn5eFQks5uMGXHgaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 14:07 edroaldo

Thank you,

Likely I have both already installed

> library('cccd')
> 
> library('proxy')
> 

fereshtehizadi avatar Jul 31 '18 14:07 fereshtehizadi

Sorry I am starting the tutorial but I am being stopped by this error firstly


> cellrouter <- computePCA(cellrouter, num.pcs = 50, seed=42) #build knn graph on the PCA/DC space

> cellrouter <- computePCA(cellrouter, num.pcs = 50, seed=42)
> plot(cellrouter@pca$sdev, xlab='PC', ylab='Standard d\
+ 

> plot(cellrouter@pca$sdev, xlab='PC', ylab='Standard deviation of PC')
> 
> cellrouter <- computeTSNE(cellrouter, num.pcs = 11, seed=42, max_iter = 1000)
> cellrouter <- customSpace(cellrouter, cellrouter@tsne$cell.embeddings)
> plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "celltype", annotation.color = 'celltype_color', showlabels = TRUE, 4.5, 3.5, filename='results/tSNE_1.pdf')
 Show Traceback
 
 Rerun with Debug
 Error in `$<-.data.frame`(`*tmp*`, "group", value = integer(0)) : 
  replacement has 0 rows, data has 209 > 
> getwd()
[1] "/Users/dicty/Downloads/fereshteh"
> plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "celltype", annotation.color = 'celltype_color', showlabels = TRUE, 4.5, 3.5, filename='/Users/dicty/Downloads/fereshteh/tSNE_1.pdf')
 Show Traceback
 
 Rerun with Debug
 Error in `$<-.data.frame`(`*tmp*`, "group", value = integer(0)) : 
  replacement has 0 rows, data has 209 > 
> plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "celltype", annotation.color = 'celltype_color', showlabels = TRUE, 4.5, 3.5, filename='/Users/dicty/Downloads/fereshteh/tSNE_1.pdf')
 Show Traceback
 
 Rerun with Debug
 Error in `$<-.data.frame`(`*tmp*`, "group", value = integer(0)) : 
  replacement has 0 rows, data has 209 
> 

fereshtehizadi avatar Jul 31 '18 14:07 fereshtehizadi

Did you run the entire cellrouter workflow? Did you perform the PCA analysis with:

cellrouter <- computePCA(cellrouter, genes.use=rownames(cellrouter@ndata), num.pcs = 50, seed=42) #build knn graph on the PCA/DC space plot(cellrouter@pca$sdev)

please show me the content of: cellrouter@pca$cell.embeddings[,1:5]

Thanks!

2018-07-31 10:24 GMT-04:00 fereshtehizadi [email protected]:

Thank you,

Likely I have both already installed

library('cccd')

library('proxy')

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409238892, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR-HCI_BbB8LoYaUvG4DJIMXNtkBUks5uMGiZgaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 14:07 edroaldo

Yes I think

> cellrouter@pca$cell.embeddings[,1:5]
                PC1          PC2           PC3          PC4          PC5
s1.1     2.84716006   12.0613450   -0.12453762  -5.80070894 -15.24746632
s1.2   -12.52056164    4.1915314    6.21418451 -13.29060438  -4.60329067
s1.3     4.87975344    8.7908584    1.74915206  -7.65141561   0.82223327
s1.4    -3.15807153   -7.9433323   -0.53798009   9.72349588  -5.07761420
s1.5   -10.38741782    3.4123047   -9.88982749   8.82482761  -4.73446601
s1.6     9.35890964   11.3499037   -2.51033278  -2.13914556  -5.82138161
s1.7    -2.95853470    3.7396515    7.88643418  -8.45253951   8.12064397
s1.8   -13.96040877    3.2134105   12.90013280 -18.47916977  -3.86694366
s1.9    12.62269026   14.2813837   -4.36467202  -3.14582589  -3.94570091
s1.10  -13.51189864   -8.4823601    4.70365933  -1.92896893  18.06708975
s1.11   10.77702898   16.6197034   -3.05938882  -8.92536947  -5.26345901
s1.12  -21.17873194  -10.3911632   -0.26966978  14.98706485  -6.79937542
s1.13  -20.15980988   -5.0841986   -0.85543028   4.89360734   0.94193886
s1.14    3.47725633   -6.7382506   19.63515527  -3.83208893 -14.66782094
s1.15   20.52214096  -31.5084043   31.97424872  15.95214823 -22.26402090
s1.16   -8.02909521   14.9779922   -8.11263284  -1.70123795 -30.78429250
s1.17  -18.70372356   -2.5036589    2.96402897  -2.89690107   3.64035918
s1.18   -4.77811741    1.8839173   10.76723951 -17.97996310  13.11135809
s1.19    1.60192010    1.0213783   -6.98422006  -4.27114213  23.35500280
s1.20  -25.55593195   -8.5166168    7.64440691  -5.55449656   4.49901862
s1.21   -1.09732097    4.4558594    5.74601070 -14.51698359   3.35351300
s1.22   -5.66364314   -9.8506360    5.23218102   2.00162861 -12.91758728
s1.23   33.66867866   10.2404249  -12.32877628  -3.30710044   8.88420970
s1.24   -5.75852681    1.1992403    3.02097505  -4.68470076   9.69171920
s1.25    7.85668122   10.7592090    0.62140464  -8.44352977  -2.18456986
s1.26  -22.53082458  -10.7173403    0.69519824  -0.81733015   4.37553340
s1.27   20.31880324  -12.8910271   10.97330766  12.86705283  -8.33655178
s1.28    3.91973882   15.2084319   -0.46358614  -8.08672594 -11.42885804
s1.29   -5.49483281    2.6777183    1.69576581  -2.66456990  -1.76273276

fereshtehizadi avatar Jul 31 '18 14:07 fereshtehizadi

You need to run the entire workflow. Are you running the tutorial line by line? It is very weird to have an error in as.dist(matrix) unless "matrix" is empty. Also, getting erros at the very first beginning is not very usual...

Can you please send me: dim(cellrouter@rawdata) dim(cellrouter@ndata) dim(cellrouter@sampTab)

cellrouter@ndata[1:5,1:5]

Something might look different with your input files... not sure what.... so I need more info...

2018-07-31 10:36 GMT-04:00 fereshtehizadi [email protected]:

Sorry I am starting the tutorial but I am being stopped by this error firstly

cellrouter <- computePCA(cellrouter, num.pcs = 50, seed=42) #build knn graph on the PCA/DC space

cellrouter <- computePCA(cellrouter, num.pcs = 50, seed=42) plot(cellrouter@pca$sdev, xlab='PC', ylab='Standard d\

plot(cellrouter@pca$sdev, xlab='PC', ylab='Standard deviation of PC')

cellrouter <- computeTSNE(cellrouter, num.pcs = 11, seed=42, max_iter = 1000) cellrouter <- customSpace(cellrouter, cellrouter@tsne$cell.embeddings) plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "celltype", annotation.color = 'celltype_color', showlabels = TRUE, 4.5, 3.5, filename='results/tSNE_1.pdf') Show Traceback

Rerun with Debug Error in $<-.data.frame(*tmp*, "group", value = integer(0)) : replacement has 0 rows, data has 209 >

getwd() [1] "/Users/dicty/Downloads/fereshteh" plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "celltype", annotation.color = 'celltype_color', showlabels = TRUE, 4.5, 3.5, filename='/Users/dicty/Downloads/fereshteh/tSNE_1.pdf') Show Traceback

Rerun with Debug Error in $<-.data.frame(*tmp*, "group", value = integer(0)) : replacement has 0 rows, data has 209 >

plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "celltype", annotation.color = 'celltype_color', showlabels = TRUE, 4.5, 3.5, filename='/Users/dicty/Downloads/fereshteh/tSNE_1.pdf') Show Traceback

Rerun with Debug Error in $<-.data.frame(*tmp*, "group", value = integer(0)) : replacement has 0 rows, data has 209

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409242986, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR35o5d8hsEi8ecd-C4KebmMl5qDxks5uMGtpgaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 14:07 edroaldo

Thank you


> dim(cellrouter@rawdata)
[1] 12293   209
> dim(cellrouter@ndata)
[1] 12293   209
> dim(cellrouter@sampTab)
[1] 209   8
> cellrouter@ndata[1:5,1:5]
                   s1.1        s1.2 s1.3       s1.4 s1.5
DDB_G0267178 0.00000000 0.009263254    0 0.01286397    0
DDB_G0267180 0.00000000 0.000000000    0 0.00000000    0
DDB_G0267182 0.00000000 0.000000000    0 0.03810585    0
DDB_G0267184 0.00000000 0.000000000    0 0.00000000    0
DDB_G0267188 0.02640801 0.000000000    0 0.01286397    0
> 

Sorry I think I can not figure out how to come up with filename like filename='/Users/dicty/Downloads/fereshteh/tSNE_1.pdf' as I am placing my working directory

I run these steps successfully but I stopped when I have filename that is why I think perhaps errors come from there

> plot(cellrouter@pca$sdev)
> plot(cellrouter@pca$sdev, xlab='PC', ylab='Standard deviation of PC')
> cellrouter <- computeTSNE(cellrouter, num.pcs = 11, seed=42, max_iter = 1000)
> cellrouter <- customSpace(cellrouter, cellrouter@tsne$cell.embeddings)
> plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "celltype", annotation.color = 'celltype_color', showlabels = TRUE, 4.5, 3.5, filename='results/tSNE_1.pdf')
 Show Traceback
 
 Rerun with Debug
 Error in `$<-.data.frame`(`*tmp*`, "group", value = integer(0)) : 
  replacement has 0 rows, data has 209 

fereshtehizadi avatar Jul 31 '18 14:07 fereshtehizadi

This looks fine... but an error in plotReducedDimension is very strange... it basically plots the output of computeTSNE...

Can you send me the info I asked for in the previous email as well? and also: cellrouter@tsne$cell.embeddings[1:5,]

Thanks!

2018-07-31 10:43 GMT-04:00 fereshtehizadi [email protected]:

Yes I think

cellrouter@pca$cell.embeddings[,1:5] PC1 PC2 PC3 PC4 PC5 s1.1 2.84716006 12.0613450 -0.12453762 -5.80070894 -15.24746632 s1.2 -12.52056164 4.1915314 6.21418451 -13.29060438 -4.60329067 s1.3 4.87975344 8.7908584 1.74915206 -7.65141561 0.82223327 s1.4 -3.15807153 -7.9433323 -0.53798009 9.72349588 -5.07761420 s1.5 -10.38741782 3.4123047 -9.88982749 8.82482761 -4.73446601 s1.6 9.35890964 11.3499037 -2.51033278 -2.13914556 -5.82138161 s1.7 -2.95853470 3.7396515 7.88643418 -8.45253951 8.12064397 s1.8 -13.96040877 3.2134105 12.90013280 -18.47916977 -3.86694366 s1.9 12.62269026 14.2813837 -4.36467202 -3.14582589 -3.94570091 s1.10 -13.51189864 -8.4823601 4.70365933 -1.92896893 18.06708975 s1.11 10.77702898 16.6197034 -3.05938882 -8.92536947 -5.26345901 s1.12 -21.17873194 -10.3911632 -0.26966978 14.98706485 -6.79937542 s1.13 -20.15980988 -5.0841986 -0.85543028 4.89360734 0.94193886 s1.14 3.47725633 -6.7382506 19.63515527 -3.83208893 -14.66782094 s1.15 20.52214096 -31.5084043 31.97424872 15.95214823 -22.26402090 s1.16 -8.02909521 14.9779922 -8.11263284 -1.70123795 -30.78429250 s1.17 -18.70372356 -2.5036589 2.96402897 -2.89690107 3.64035918 s1.18 -4.77811741 1.8839173 10.76723951 -17.97996310 13.11135809 s1.19 1.60192010 1.0213783 -6.98422006 -4.27114213 23.35500280 s1.20 -25.55593195 -8.5166168 7.64440691 -5.55449656 4.49901862 s1.21 -1.09732097 4.4558594 5.74601070 -14.51698359 3.35351300 s1.22 -5.66364314 -9.8506360 5.23218102 2.00162861 -12.91758728 s1.23 33.66867866 10.2404249 -12.32877628 -3.30710044 8.88420970 s1.24 -5.75852681 1.1992403 3.02097505 -4.68470076 9.69171920 s1.25 7.85668122 10.7592090 0.62140464 -8.44352977 -2.18456986 s1.26 -22.53082458 -10.7173403 0.69519824 -0.81733015 4.37553340 s1.27 20.31880324 -12.8910271 10.97330766 12.86705283 -8.33655178 s1.28 3.91973882 15.2084319 -0.46358614 -8.08672594 -11.42885804 s1.29 -5.49483281 2.6777183 1.69576581 -2.66456990 -1.76273276

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409245594, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR8f32diB2bb9N-b2-kbyYTH7wYAnks5uMG0KgaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 14:07 edroaldo

Thanks


> dim(cellrouter@rawdata)
[1] 12293   209
> dim(cellrouter@ndata)
[1] 12293   209
> dim(cellrouter@sampTab)
[1] 209   8
> cellrouter@ndata[1:5,1:5]
                   s1.1        s1.2 s1.3       s1.4 s1.5
DDB_G0267178 0.00000000 0.009263254    0 0.01286397    0
DDB_G0267180 0.00000000 0.000000000    0 0.00000000    0
DDB_G0267182 0.00000000 0.000000000    0 0.03810585    0
DDB_G0267184 0.00000000 0.000000000    0 0.00000000    0
DDB_G0267188 0.02640801 0.000000000    0 0.01286397    0
> 


> cellrouter@tsne$cell.embeddings[1:5,]
         tSNE 1     tSNE 2
s1.1 -3.9703770  3.0987432
s1.2  1.1808994  4.4540186
s1.3 -1.9516066  1.3899315
s1.4  0.1912229  0.1931082
s1.5  1.7542882 -5.6374750
>

fereshtehizadi avatar Jul 31 '18 14:07 fereshtehizadi

Everything look just fine... very strange...

You can try this to save in your local folder:

plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "celltype", annotation.color = 'celltype_color', showlabels = TRUE, 4.5, 3.5, filename='tSNE_1.pdf')

does it work?

2018-07-31 10:55 GMT-04:00 fereshtehizadi [email protected]:

Thanks

dim(cellrouter@rawdata) [1] 12293 209 dim(cellrouter@ndata) [1] 12293 209 dim(cellrouter@sampTab) [1] 209 8 cellrouter@ndata[1:5,1:5] s1.1 s1.2 s1.3 s1.4 s1.5 DDB_G0267178 0.00000000 0.009263254 0 0.01286397 0 DDB_G0267180 0.00000000 0.000000000 0 0.00000000 0 DDB_G0267182 0.00000000 0.000000000 0 0.03810585 0 DDB_G0267184 0.00000000 0.000000000 0 0.00000000 0 DDB_G0267188 0.02640801 0.000000000 0 0.01286397 0

cellrouter@tsne$cell.embeddings[1:5,] tSNE 1 tSNE 2 s1.1 -3.9703770 3.0987432 s1.2 1.1808994 4.4540186 s1.3 -1.9516066 1.3899315 s1.4 0.1912229 0.1931082 s1.5 1.7542882 -5.6374750

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409250043, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR__tLttO7fmQTLllpReEnf9w8QYDks5uMG_4gaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 14:07 edroaldo

It worked thanks a lot for your time

I am eagerly going through the rest of tutorial

fereshtehizadi avatar Jul 31 '18 14:07 fereshtehizadi

You seem to be mixing the tutorial with outr data without update information. If you are using your data, you should do:

plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "seuratClusters", annotation.color = 'seuratClusters_color', showlabels = TRUE, 4.5, 3.5, filename='tSNE_1.pdf')

You need to change the code to reflect your annotations. Please, try this and let me know...

2018-07-31 10:57 GMT-04:00 Edroaldo Lummertz da Rocha [email protected]:

Everything look just fine... very strange...

You can try this to save in your local folder:

plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "celltype", annotation.color = 'celltype_color', showlabels = TRUE, 4.5, 3.5, filename='tSNE_1.pdf')

does it work?

2018-07-31 10:55 GMT-04:00 fereshtehizadi [email protected]:

Thanks

dim(cellrouter@rawdata) [1] 12293 209 dim(cellrouter@ndata) [1] 12293 209 dim(cellrouter@sampTab) [1] 209 8 cellrouter@ndata[1:5,1:5] s1.1 s1.2 s1.3 s1.4 s1.5 DDB_G0267178 0.00000000 0.009263254 0 0.01286397 0 DDB_G0267180 0.00000000 0.000000000 0 0.00000000 0 DDB_G0267182 0.00000000 0.000000000 0 0.03810585 0 DDB_G0267184 0.00000000 0.000000000 0 0.00000000 0 DDB_G0267188 0.02640801 0.000000000 0 0.01286397 0

cellrouter@tsne$cell.embeddings[1:5,] tSNE 1 tSNE 2 s1.1 -3.9703770 3.0987432 s1.2 1.1808994 4.4540186 s1.3 -1.9516066 1.3899315 s1.4 0.1912229 0.1931082 s1.5 1.7542882 -5.6374750

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409250043, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR__tLttO7fmQTLllpReEnf9w8QYDks5uMG_4gaJpZM4VoF6T .

-- Edroaldo

-- Edroaldo

edroaldo avatar Jul 31 '18 14:07 edroaldo

You do not have " annotation = "celltype" " in your analysis, this is specific to the tutorial, where "celltype" was previously defined at the beginning of the analysis.

2018-07-31 10:59 GMT-04:00 Edroaldo Lummertz da Rocha [email protected]:

You seem to be mixing the tutorial with outr data without update information. If you are using your data, you should do:

plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "seuratClusters", annotation.color = 'seuratClusters_color', showlabels = TRUE, 4.5, 3.5, filename='tSNE_1.pdf')

You need to change the code to reflect your annotations. Please, try this and let me know...

2018-07-31 10:57 GMT-04:00 Edroaldo Lummertz da Rocha [email protected] :

Everything look just fine... very strange...

You can try this to save in your local folder:

plotReducedDimension(cellrouter, reduction.type = 'tsne', dims.use = c(1,2), annotation = "celltype", annotation.color = 'celltype_color', showlabels = TRUE, 4.5, 3.5, filename='tSNE_1.pdf')

does it work?

2018-07-31 10:55 GMT-04:00 fereshtehizadi [email protected]:

Thanks

dim(cellrouter@rawdata) [1] 12293 209 dim(cellrouter@ndata) [1] 12293 209 dim(cellrouter@sampTab) [1] 209 8 cellrouter@ndata[1:5,1:5] s1.1 s1.2 s1.3 s1.4 s1.5 DDB_G0267178 0.00000000 0.009263254 0 0.01286397 0 DDB_G0267180 0.00000000 0.000000000 0 0.00000000 0 DDB_G0267182 0.00000000 0.000000000 0 0.03810585 0 DDB_G0267184 0.00000000 0.000000000 0 0.00000000 0 DDB_G0267188 0.02640801 0.000000000 0 0.01286397 0

cellrouter@tsne$cell.embeddings[1:5,] tSNE 1 tSNE 2 s1.1 -3.9703770 3.0987432 s1.2 1.1808994 4.4540186 s1.3 -1.9516066 1.3899315 s1.4 0.1912229 0.1931082 s1.5 1.7542882 -5.6374750

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409250043, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR__tLttO7fmQTLllpReEnf9w8QYDks5uMG_4gaJpZM4VoF6T .

-- Edroaldo

-- Edroaldo

-- Edroaldo

edroaldo avatar Jul 31 '18 15:07 edroaldo

Exactly the problem as you mentioned was annotation = "seuratClusters", annotation.color = 'seuratClusters_color',

fereshtehizadi avatar Jul 31 '18 15:07 fereshtehizadi

Awesome! That's great! Just need to be careful changing which metadata column if you want to use (seuratClusters, potentially "celltype" if you further annotate your clusters, things like that). This was designed to be very flexible but it requires chaning some parameters to select the relevant metadata.

Thanks!

2018-07-31 11:02 GMT-04:00 fereshtehizadi [email protected]:

It worked thanks a lot for your time

I am eagerly going through the rest of tutorial

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409252187, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR_ouPNYiCvssTTbUNfOv_DO6DcaWks5uMHFpgaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 15:07 edroaldo

Fantastic! Glad it is working! Let me know if you have other issues or suggestions to further improve CellRouter!

Thanks!

2018-07-31 11:04 GMT-04:00 fereshtehizadi [email protected]:

Exactly the problem as you mentioned was annotation = "seuratClusters", annotation.color = 'seuratClusters_color',

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409253072, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR7EYD2r7mofoGXF3d9O0eOV15kqzks5uMHH1gaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 15:07 edroaldo

Thanks a lot for your time

fereshtehizadi avatar Jul 31 '18 15:07 fereshtehizadi

You are most welcome!

2018-07-31 11:10 GMT-04:00 fereshtehizadi [email protected]:

Thanks a lot for your time

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409255586, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqURzereC3safBHsKOFHTKDZRc3WuMhks5uMHN4gaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 15:07 edroaldo

I am really sorry, but I am most interested in trajectory analysis, I have done the tutorial until this step that I stopped by an error

> cellrouter <- findPaths(cellrouter, column='seuratClusters', libdir, paste(getwd(), 'Users/dicty/Downloads/fereshteh', sep='/'), method="graph")
 Show Traceback
 
 Rerun with Debug
 Error in base::order(..., na.last = na.last, decreasing = decreasing) : 
  argument 1 is not a vector > 
> cellrouter <- findPaths(cellrouter, column='seuratClusters',paste(getwd(), 'Users/dicty/Downloads/fereshteh', sep='/'), method="graph")
 Show Traceback
 
 Rerun with Debug
 Error in base::order(..., na.last = na.last, decreasing = decreasing) : 
  argument 1 is not a vector > 
> ranks <- c('path_cost', 'path_flow', 'rank', 'length')
> 
> cellrouter <- processTrajectories(cellrouter, rownames(cellrouter@ndata), path.rank=ranks[3], num.cells = 3, neighs = 3,column.ann = 'seuratClusters', column.color = 'seuratClusters_color')
[1] "parsing trajectory information"
 Show Traceback
 
 Rerun with Debug
 Error in complete.cases(paths) : 
  no input has determined the number of cases 

fereshtehizadi avatar Jul 31 '18 15:07 fereshtehizadi

I strongly recommend you to create a folder "results" in your working directory and then a folder "paths" inside your folder results, to make the working directory as "clean" as possible. In the lines bellow:

filename <- "results/paths/cell_edge_weighted_network.txt" write.table(cellrouter@graph$edges, file=filename, sep='\t', row.names=FALSE, col.names = FALSE, quote=FALSE) #input network

Where are you saving cell_edge_weighted_network.txt. I need to know the code you are running otherwise I cannot debug it. Please, provide me all your commands before the error message, starting at, for example, cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'seuratClusters', num.pcs = 20, sim.type = 'jaccard')

Thanks!

2018-07-31 11:32 GMT-04:00 fereshtehizadi [email protected]:

I am really sorry, but I am most interested in trajectory analysis, I have done the tutorial until this step that I stopped by an error

cellrouter <- findPaths(cellrouter, column='seuratClusters', libdir, paste(getwd(), 'Users/dicty/Downloads/fereshteh', sep='/'), method="graph") Show Traceback

Rerun with Debug Error in base::order(..., na.last = na.last, decreasing = decreasing) : argument 1 is not a vector >

cellrouter <- findPaths(cellrouter, column='seuratClusters',paste(getwd(), 'Users/dicty/Downloads/fereshteh', sep='/'), method="graph") Show Traceback

Rerun with Debug Error in base::order(..., na.last = na.last, decreasing = decreasing) : argument 1 is not a vector >

ranks <- c('path_cost', 'path_flow', 'rank', 'length')

cellrouter <- processTrajectories(cellrouter, rownames(cellrouter@ndata), path.rank=ranks[3], num.cells = 3, neighs = 3,column.ann = 'seuratClusters', column.color = 'seuratClusters_color') [1] "parsing trajectory information" Show Traceback

Rerun with Debug Error in complete.cases(paths) : no input has determined the number of cases

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edroaldo/cellrouter/issues/13#issuecomment-409263618, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqURz5HJ9f9_mesUjoxxrF-T_Bb_9kDks5uMHiIgaJpZM4VoF6T .

-- Edroaldo

edroaldo avatar Jul 31 '18 15:07 edroaldo

I started from trajectory analysis between clusters identified by CellRouter not Paul study

> cellrouter <- buildKNN(cellrouter, k = 10, column.ann = 'seuratClusters',num.pcs = 20, sim.type = 'jaccard')
[1] "building k-nearest neighbors graph"
[1] "updating CellRouter object"
Warning message:
In write.graph.gml(graph, file, ...) :
  At foreign.c:2616 :A boolean graph attribute was converted to numeric
> plotKNN(cellrouter, reduction.type = 'tsne', column.ann = 'seuratClusters', column.color = 'seuratClusters_color', width = 5, height = 4, filename='results/knn_tsne_CellRouter_clusters.pdf') #increase legend size
> 
> plotReducedDimension(cellrouter, reduction.type = 'tsne', annotation="seuratClusters", annotation.color = 'seuratClusters_color',showlabels = TRUE, width = 4.5, height = 3.5, filename='results/tSNE_graphClustering_clusters.pdf')
> 
> filename <- "results/paths/cell_edge_weighted_network.txt"
> 
> write.table(cellrouter@graph$edges, file=filename, sep='\t', row.names=FALSE, col.names = FALSE, quote=FALSE) #input network
> 
> sources <- c('0')
> targets <- setdiff(as.vector(cellrouter@sampTab$population), sources)
> 
> methods <- c("euclidean", "maximum", "manhattan","canberra","binary", 'graph') #graph for distances in KNN
> 
> cellrouter <- findPaths(cellrouter, column='seuratClusters', libdir, paste(getwd(), 'results/paths', sep='/'), method="graph")
 Show Traceback
 
 Rerun with Debug
 Error in base::order(..., na.last = na.last, decreasing = decreasing) : 
  argument 1 is not a vector > 
> 

I guess maybe problem comes from libdir that I did not figure out how to define

libdir <- '~/path/to/library/folder/CellRouter/'

libdir <- '~/Documents/Projects/cellrouter-master/CellRouter/'

However I have already downloaded six .jar files from lib file and put them in my working directory

fereshtehizadi avatar Jul 31 '18 15:07 fereshtehizadi