phipsonlab / cellXY

R package to predict sex of single cells and identify Male/Female doublets using machine learning approaches
GNU General Public License v3.0
8 stars 4 forks source link

Classifying sex in a mouse dataset #3

Open dianajzajac opened 4 months ago

dianajzajac commented 4 months ago

Hi, I am attempting to use the classifySex function for mouse data, I defined genome='Mm' but I believe it is still attempting to classify using the human reference XIST instead of the mouse Xist. Below I am pasting my code and the error I am currently receiving.

`

library(Seurat) library(CellBench) library(org.Hs.eg.db) library(org.Mm.eg.db)

library(cellXY)

Load so

so <- readRDS(file = filtpath)

DefaultAssay(so) <- 'RNA' so_temp <- so

Use sparse matrix to avoid memory issues

counts <- so_temp@assays$RNA@counts print(head(counts))

Map SYMBOL to ENSEMBL

ann <- select(org.Mm.eg.db, keys=rownames(counts), columns=c("ENSEMBL","SYMBOL"), keytype="SYMBOL")

Match and replace row names

m <- match(rownames(counts), ann$SYMBOL) valid_ann <- ann[!is.na(m), ] valid_counts <- counts[match(valid_ann$SYMBOL, rownames(counts)), ] rownames(valid_counts) <- valid_ann$ENSEMBL

print(head(valid_counts))

print("Now to make counts a matrix...")

Ensure valid_counts is dense if classifySex requires a dense matrix

valid_counts_dense <- as.matrix(valid_counts)

print("Now to classify sex......")

Classify sex

sex <- classifySex(valid_counts, genome="Mm") print(head(sex))

Generate boxplot

table(sex$prediction) boxplot(valid_counts["Xist",] ~ sex$prediction)

`

the error is:

          289907cell/s are unable to be classified due to an abundance of zeroes on X and Y chromosome genes

Error: variables ‘XIST’, ‘superX’, ‘superY’ were specified with different types from the fit

kobeho24 commented 1 week ago

same problem here

eandresleon commented 13 hours ago

Hi, I recomend you to use the old version included in the speckle package (0.03):

library(devtools)
devtools::install_github("Oshlack/speckle")