Entering edit mode
11 months ago
Nitin
•
0
I am trying to predict the cell type using the scPred package. I use Posit R-Studio IDE on the AWS sagemaker.
I am not able to get any output when running the following command
# load the data
alldata <- readRDS("data/results/run4.rds")
ctrl = alldata[, alldata$orig.ident == 'ctrl']
# set active assay to RNA
ctrl@active.assay = 'RNA'
ctrl
reference <- scPred::pbmc_1
reference
reference <- reference %>%
NormalizeData() %>%
FindVariableFeatures() %>%
ScaleData() %>%
RunPCA(verbose = F) %>%
RunUMAP(dims = 1:30)
#Set the identity resolution 0.5
ctrl <- SetIdent(ctrl, value = "CCA_snn_res.0.5")
ctrl <- ctrl %>%
NormalizeData() %>%
FindVariableFeatures() %>%
ScaleData() %>%
RunPCA(verbose = F) %>%
RunUMAP(dims = 1:30)
# Transfer Label
transfer.anchors <- FindTransferAnchors(reference = reference, query = ctrl,
dims = 1:30)
predictions <- TransferData(anchorset = transfer.anchors, refdata = reference$cell_type,
dims = 1:30)
ctrl <- AddMetaData(object = ctrl, metadata = predictions)
## scPred
reference <- getFeatureSpace(reference, "cell_type")
reference <- trainModel(reference)
get_scpred(reference)
Till here everything works fine, but the following code fails
ctrl <- scPredict(ctrl, reference)
OUTPUT
Matching reference with new dataset...
2000 features present in reference loadings
1773 features shared between reference and new dataset
88.65% of features in the reference are present in new dataset
Error in `GetAssayData()`:
! `assay` must be one of "RNA", not "data".
Backtrace:
1. scPred::scPredict(ctrl, reference)
2. scPred::project_query(...)
4. SeuratObject:::GetAssayData.Seurat(assay = "data")
Error in GetAssayData(new, "data") :
Please help
Hello,
I had the exact same issue and found there is a bug in the package. Specifically, in scPred/R/project_query.R on line 87. The line has the following code:
The Seurat function
GetAssayData()
requires the third positional argument to be stated asslot="data"
; otherwise, its second positional argument assay expects a suitable value like "RNA" or another type of assay (and will throw the error you cited). Here is the correction of line 87 in the script:When I cloned the repo to the remote machine I perform work on, I customized the package by modifying this line and successfully implemented it in my R runtime environment (R 4.3).
I've notified the maintainer of the package of this bug.
Hope this helps.
Maze
This is correct, after updating Seurat to v5 the error occurs due to
GetAssayData()
now requiring a named parameter (and the second position now defaulting to 'assay').Worth noting the 'slot' param is now deprecated as per the SeuratObject documentation. So the pull request uses
layer="data"
for continued functionality.scPred with the updated call for the v5 function can be installed by referencing the specific pull request:
Are you sure this is the right way to set the active assay?
yes, also I tried with
Can you run these commands before setting the default assay and show us the output:
Here is the output
That does not make sense to me. You don't have an RNA assay, yet you're assigning it as the default assay. Does that add up to you?
yes, but when check the
Oh, OK. I guess I was wrong. What does
Assays(ctrl)
give you? Also, what doesclass(ctrl[["RNA"]])
say?NOTE - Also I tried to run the scPRED as per the link https://powellgenomicslab.github.io/scPred/articles/introduction.html I have the same issue at the same step.
Here are the outputs you asked for
You're going to need to consult a bioinformatician close to you or wait for a Seurat expert here to help you out.