edroaldo / cellrouter

Reconstruction of complex single-cell trajectories using CellRouter
45 stars 21 forks source link

Function findsubpopulations #5

Open LaptopY opened 6 years ago

LaptopY commented 6 years ago

Hello, Thank you for your previous answer. While I am able to find the subpopulations with the data set you use, I am unable to do the same with my own data set (I tried with different k number). I obtain the following message.

cellrouter <- findsubpopulations (cellrouter, 5, 'jaccard') [1] "building k-nearest neighbors graph" [1] "discoverying subpopulation structure"

Error in simple_vs_index(x, ii, na_ok) : Unknown vertex selected

I am not able to understand the error message, I tried to find if the presence of na was a problem with the function

which(is.na(mydata), arr.ind=TRUE)

But it seems that my data set doesn't contain na Thank you

edroaldo commented 6 years ago

Could you please let me know your igraph version? or sessionInfo()

Thanks!

2018-04-05 15:27 GMT-04:00 LaptopY notifications@github.com:

Hello, Thank you for your previous answer. While I am able to find the subpopulations with the data set you use, I am unable to do the same with my own data set (I tried with different k number). I obtain the following message.

cellrouter <- findsubpopulations (cellrouter, 5, 'jaccard') [1] "building k-nearest neighbors graph" [1] "discoverying subpopulation structure"

Error in simple_vs_index(x, ii, na_ok) : Unknown vertex selected

I am not able to understand the error message, I tried to find if the presence of na was a problem with the function

which(is.na(mydata), arr.ind=TRUE)

But it seems that my data set doesn't contain na Thank you

— 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/5, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqUR4a8iFwpiRD8XfpemqdWQPuWrdATks5tlnAOgaJpZM4TJBn2 .

-- Edroaldo

LaptopY commented 6 years ago

Thank you for your answer

package.version("igraph") [1] "1.2.1"

edroaldo commented 6 years ago

You igraph version is fine. Can you please send the corresponding code that you are using, for your own data?

Thanks!

2018-04-05 15:59 GMT-04:00 LaptopY notifications@github.com:

Thank you for your answer

package.version("igraph") [1] "1.2.1"

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

-- Edroaldo

LaptopY commented 6 years ago

I am not sure to understand what you mean by "the corresponding code that you are using", I am new in R, I apologize for that.

LaptopY commented 6 years ago

If you mean the previous lines

I have :

matrix tsne obtention

matrix <- as.data.frame(tsne_result$Y) colnames(matrix) <- c('tSNE1', 'tSNE2')

selecting genes to use as regulated along developmental trajectories

pca <- prcomp(t(mydata), scale=TRUE, center=TRUE) loadings <- pca$rotation num_pc <- 5 quantile <- 0.975 genes2use <- unique(as.vector(unlist(apply(loadings[,1:num_pc], 2, function(x){names(x[which(abs(x) >= quantile(x, quantile))])}))))

Subpopulation identification and gene signatures with CellRouter

cellrouter <- CellRouter(expdata=mydata, annotations=colnames(mydata))

[1] "Initializing CellRouter object"

cellrouter@rdimension <- matrix

cellrouter <- findsubpopulations(cellrouter, 7, 'jaccard')

edroaldo commented 6 years ago

Can you also show me how you are obtaining your matrix object using the Rtsne function?

The error message is not familiar to me so I am trying to understand the steps that you are following.

Thanks!

On Thu, Apr 5, 2018, 4:32 PM LaptopY notifications@github.com wrote:

If you mean the previous lines

I have : matrix tsne obtention

matrix <- as.data.frame(tsne_result$Y) colnames(matrix) <- c('tSNE1', 'tSNE2') selecting genes to use as regulated along developmental trajectories

pca <- prcomp(t(mydata), scale=TRUE, center=TRUE) loadings <- pca$rotation num_pc <- 5 quantile <- 0.975 genes2use <- unique(as.vector(unlist(apply(loadings[,1:num_pc], 2, function(x){names(x[which(abs(x) >= quantile(x, quantile))])})))) Subpopulation identification and gene signatures with CellRouter

cellrouter <- CellRouter(expdata=mydata, annotations=colnames(mydata)) [1] "Initializing CellRouter object"

cellrouter@rdimension <- matrix

cellrouter <- findsubpopulations(cellrouter, 7, 'jaccard')

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

LaptopY commented 6 years ago

The data come from 10X genomic so I used the package CellrangerRKit. They provide steps to reanalyze data as following

set.seed(0) n_clust <- 7 pca_result <- run_pca(gbm) tsne_result <- run_tsne(pca_result) matrix <- as.data.frame(tsne_result$Y) colnames(matrix) <- c('tSNE1', 'tSNE2')

I obtain the same tsne plot that they provided, so I don't think that the matrix was the problem. They provide the normalized matrix also and I just transformed the ensembl genes in symbol and I remove genes with 0 variance accross the cells as in your tutorial. I also need to tranform into a dataframe, may be it is the problem?

mydata<-as.data.frame(as.matrix(mydata))

Remove genes with zero variance across all cells

var <- apply(mydata, 1, var) var <- var[which(var > 0)] mydata <- mydata[names(var),]

Thank you

LaptopY commented 6 years ago

The rownames of my "matrix" ( 2 colums and number of cells in row) didn't correspond to the colnames of the dataframe/dataset "mydata" (containing the genes in rownames and the cells in column). I assume it's a big issue.

edroaldo commented 6 years ago

Yes. This should be the cause of your problem. Try something like: rownames(matrix) = colnames (mydata)

This should solve the problem. Let me know if that works.

Thanks!

On Thu, Apr 5, 2018, 5:24 PM LaptopY notifications@github.com wrote:

The rownames of my "matrix" ( 2 colums and number of cells in row) didn't correspond to the colnames of the dataframe/dataset "mydata" (containing the genes in rownames and the cells in column). I assume it's a big issue.

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

LaptopY commented 6 years ago

Yes !!!! It works, Thank you so much !!!

edroaldo commented 6 years ago

That's great news! Thank you for your interest in our work!

2018-04-05 19:11 GMT-04:00 LaptopY notifications@github.com:

Yes !!!! It works, Thank you so much !!!

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

-- Edroaldo

fereshtehizadi commented 6 years ago

Sorry, I tried to follow Mouse bone marrow single-cell RNA-seq

tutorial but likely for some reasons I am not able to complete that, may I please ask for your kindly guide

> matrix <- get(load('results/matrix.R'))
> ndata <- get(load('results/normalized_expression.R'))
> fdata <- get(load('results/filtered_expression.R'))
> colnames(matrix) <- c('tSNE1', 'tSNE2')
> genes <- sapply(strsplit(rownames(ndata), split='__', fixed=TRUE), function(x){x[1]})
> map <- data.frame(id=rownames(ndata), symbol=genes, stringsAsFactors = FALSE)
> View(map)
> ndata <- averageIds(ndata, map, 'symbol')
Error in averageIds(ndata, map, "symbol") : 
  could not find function "averageIds"

# here I used ndata itself to pass this error
> var <- apply(ndata, 1, var)
> var <- var[which(var > 0)]
> ndata <- ndata[names(var),]
> pca <- prcomp(t(ndata), scale=TRUE, center=TRUE)
> loadings <- pca$rotation
> num_pc <- 5
> quantile <- 0.975
> genes2use <- unique(as.vector(unlist(apply(loadings[,1:num_pc], 2, function(x){names(x[which(abs(x) >= quantile(x, quantile))])}))))

> cellrouter <- CellRouter(expdata=ndata, annotations=colnames(ndata))
Error in .local(.Object, ...) : 
  unused arguments (expdata = ndata, annotations = colnames(ndata))
# here I used cellrouter <- CellRouter(ndata) instead of the code in tutorial to pass this error 

> cellrouter@rdimension <- matrix
> cellrouter <- findsubpopulations(cellrouter, 5, 'jaccard', 'results/kNN_network.gml')
Error in findsubpopulations(cellrouter, 5, "jaccard", "results/kNN_network.gml") : 
  could not find function "findsubpopulations"
> 
edroaldo commented 6 years ago

I am sorry but the old tutorials do not work in the current version of cellrouter. You can use the dataset in the context of the current cellrouter tutorials. I apologize.

Thanks!

On Fri, Aug 3, 2018, 2:29 PM fereshtehizadi notifications@github.com wrote:

Sorry, I tried to follow this tutorial but likely for some reasons I am not able to complete that

matrix <- get(load('results/matrix.R')) ndata <- get(load('results/normalized_expression.R')) fdata <- get(load('results/filtered_expression.R')) colnames(matrix) <- c('tSNE1', 'tSNE2') genes <- sapply(strsplit(rownames(ndata), split='__', fixed=TRUE), function(x){x[1]}) map <- data.frame(id=rownames(ndata), symbol=genes, stringsAsFactors = FALSE) View(map) ndata <- averageIds(ndata, map, 'symbol') Error in averageIds(ndata, map, "symbol") : could not find function "averageIds"

here I used data itself to pass this error

var <- apply(ndata, 1, var) var <- var[which(var > 0)] ndata <- ndata[names(var),] pca <- prcomp(t(ndata), scale=TRUE, center=TRUE) loadings <- pca$rotation num_pc <- 5 quantile <- 0.975 genes2use <- unique(as.vector(unlist(apply(loadings[,1:num_pc], 2, function(x){names(x[which(abs(x) >= quantile(x, quantile))])}))))

cellrouter <- CellRouter(expdata=ndata, annotations=colnames(ndata)) Error in .local(.Object, ...) : unused arguments (expdata = ndata, annotations = colnames(ndata))

here I used cellrouter <- CellRouter(ndata) to pass this error

cellrouter@rdimension <- matrix cellrouter <- findsubpopulations(cellrouter, 5, 'jaccard', 'results/kNN_network.gml') Error in findsubpopulations(cellrouter, 5, "jaccard", "results/kNN_network.gml") : could not find function "findsubpopulations"

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