-1
$\begingroup$

I'm trying to subset my seurat object based on colnames. I have gone ahead and labeled each cluster and now I want to subset all the colnames that are in Cancer_human for human_colnames and all the barcodes that are not in Cancer_human for mouse_colnames but get an error.

human_colnames = colnames(scData[,scData$cell_ann == "Cancer_human"])
mouse_colnames = colnames(scData[,!scData$cell_ann == "Cancer_human"])

Error in `[.Seurat`(scData, , scData$cell_ann == "Cancer_human") : Incorrect number of logical values provided to subset cells
$\endgroup$
1
  • $\begingroup$ The code could only make sense if the data is a square, equal number of rows and columns. At the moment you are getting index from row comparison, then using that index to subset columns. Also, please provide a reproducible example data for testing, dput(myData). $\endgroup$
    – zx8754
    Aug 17 at 14:44
0
$\begingroup$

Answer from @ram-rs, converted from comment:

I don't think it works that way, mmpp. The [ operation needs either a list of names, indexes or a boolean vector for each of the row and column spots to subset along that dimension, and you cannot use a boolean vector based on rows to subset columns (that's what you're doing here). Google how to subset columns in R.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.