Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with selectFeatures #16

Open
massonix opened this issue Jun 25, 2019 · 5 comments
Open

Problem with selectFeatures #16

massonix opened this issue Jun 25, 2019 · 5 comments

Comments

@massonix
Copy link

Dear scmap team,

I am trying to project my scRNA-seq dataset against the Tabula Muris droplet-based reference (which I download from here). This is my code

# Load the reference matrix and metadata
metadata_url <- "https://raw.githubusercontent.com/czbiohub/tabula-muris-vignettes/master/data/TM_droplet_metadata.csv"
tm_mat <- readRDS("data/TM_droplet_mat.rds")
tm_metadata <- read_csv(metadata_url, col_names = TRUE)

# Create SingleCellExperiment object
tm_metadata <- as.data.frame(tm_metadata)
rownames(tm_metadata) <- tm_metadata$cell
tm <- SingleCellExperiment(
  assays = list(counts = tm_mat),
  colData = tm_metadata
)

# Index reference dataset
logcounts(tm) <- log((counts(tm) / colSums(counts(tm)) * 10000) + 1)
rowData(tm)$feature_symbol <- rownames(tm)
tm <- selectFeatures(tm, suppress_plot = FALSE)

However, I get this error: Error in rowSums(count == 0) :
'x' must be an array of at least two dimensions

I looked for this command in your code but couldn't find it. If you could help me with this it would be very helpful. Thanks in advance for that and for your packages, they are amazing!

Best

Ramon

@wikiselev
Copy link
Member

Hi, thanks for your message! I've looked into it and it seems that the error occurs here:

scmap/R/Utils.R

Line 151 in d8160c7

dropouts <- rowSums(count == 0)/cols * 100

However, if I run the inner scripts manually there is no error, i.e.:

count <- as.matrix(counts(tm))
dropouts <- rowSums(count == 0)/cols * 100

Not sure what is going now, will need to spend more time on it.

@massonix
Copy link
Author

massonix commented Jun 26, 2019

I will check this for the moment, thank you very much!

@massonix
Copy link
Author

massonix commented Jun 26, 2019

Indeed, if I copy the 3 functions (selectFeatures, linearModel and ggplot_features) from this repo to my code it works fine. However, I still get the same error when running the function loaded by the package...

EDIT: A similar issue happens with indexClusters. When I run the package version I get the following error: Error: Columns 4, 5, 6, 7, 8, ... cannot have NA as name; but when I copy&paste the function it works fine

@wikiselev
Copy link
Member

I feel the problem is that your count matrix is in sparse format:

> counts(tm)[1:3,1:3]
3 x 3 sparse Matrix of class "dgCMatrix"
              10X_P4_0_AAACCTGAGATTACCC 10X_P4_0_AAACCTGAGTGCCAGA
0610005C13Rik                         .                         .
0610007C21Rik                         3                         1
0610007L01Rik                         .                         1
              10X_P4_0_AAACCTGCAAATCCGT
0610005C13Rik                         .
0610007C21Rik                         3
0610007L01Rik                         .

Does it work if you just convert it to normal matrix? I haven't sorted out yet how to deal with the sparse formats...

@yasinkaymaz
Copy link

I also had the same issue and found the discussion here. The errors below seem to disappear when I convert the dgCMatrix to normal matrix:

Error` in rowSums(count == 0) :
'x' must be an array of at least two dimensions
Calls: selectFeatures -> selectFeatures -> linearModel -> rowSums
Execution halted

Error in rowSums(log_count[dropouts_filter, ]) :
'x' must be an array of at least two dimensions
Calls: selectFeatures -> selectFeatures -> linearModel -> rowSums
Execution halted

counts(que_sce) <- as.matrix(counts(que_sce))

logcounts(que_sce) <- as.matrix(logcounts(que_sce))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants