I'm following a tutorial for an R package called "pagoda2" (http://pklab.med.harvard.edu/peterk/p2/walkthrough.nb.html) - the tutorial loads data generated by a bioinformatic company CellRanger, and subsets the data according to a feature of the dataset's metadata (whether the data is from the control or experimental group). I've been trying to load and subset my own data (it's generated in the same way by CellRanger, so it should be more or less equivalent) but I get an error:
CTRL.data <- read.10x.matrices(list(CTRL="/home/atp9753/filtered_feature_bc_matrix/"))[[1]]
STIM.data <- read.10x.matrices(list(CTRL="/home/atp9753/filtered_feature_bc_matrix/"))[[2]]
reading 1 dataset(s)
.
done
Error in read.10x.matrices(list(CTRL = "/home/atp9753/filtered_feature_bc_matrix/"))[[1]] :
this S4 class is not subsettable
I saw one recommendation to convert the dataset to a dataframe, but that returned an error for my data:
CTRL.data <- as.data.frame(read.10x.matrices(list(CTRL="/home/atp9753/filtered_feature_bc_matrix/")))[[1]]
Error in as.data.frame.default(read.10x.matrices(list(CTRL = "/home/atp9753/filtered_feature_bc_matrix/"))) : cannot coerce class ‘structure("dgCMatrix", package = "Matrix")’ to a data.frame
I've been googling around and have looked around this site but haven't been able to find anything. I've looked at this post about subsetting an S4 matrix in R (Subsetting S4 matrix in R) but it wasn't clear to me how to subset the data according to metadata. Is it possible that the data from the tutorial is not an S4 class? Is it possible to convert my data to some for that could be subsetted?
EDIT:
This is the output of "class(read.10x.matrices(...))":
> class(read.10x.matrices(list(path="/home/atp9753/filtered_feature_bc_matrix/")))
reading 1 dataset(s)
.
done
[1] "dgCMatrix"
attr(,"package")
[1] "Matrix"