problem extracting data from a dataset
1
0
Entering edit mode
2.3 years ago
max • 0

Hi All,

The function "rownames" and "colnames" extract row and column labels from the dataset.

For some specific purpose, I need to extract a column of strings from a dataset that doesn't seem compatible with the two functions above. It looks like this: dataset sample

And after running colnames it reports null. report

I just wonder if there is any way to extract the first column of this dataset! Any suggestions will be highly appreciated!

thanks

Best,

Max

scRNA-seq dataset seurat • 1.4k views
ADD COMMENT
0
Entering edit mode

how is the dataset created?

ADD REPLY
0
Entering edit mode

by extracting active.ident of a very weird dataset GSE154659_C57_Raw_counts

ADD REPLY
0
Entering edit mode

Thank you for detailed answer. What do you want to extract from counts (RDS object) and how did you extract the counts? In the mean time, try this:

counts= readRDS("<input_counts.rds>")
ADD REPLY
0
Entering edit mode

Thank you for the suggestion! I want to extract a string containing cell name and experiment type from the active. ident. However, its syntax does not allow me to do so. I simply ran addset <- object@active ident to extract it. the type of it

ADD REPLY
0
Entering edit mode
2.3 years ago
jv ★ 1.8k

is any way to extract the first column of this dataset

it looks like you are using R in which case if this is a matrix of data frame then the first column of cells can be accessed using base notations like:

addset[,1]

However this is not the same as colnames or rownames and it is rather strange that your addset object doesn't have row or column names which makes me think that this object is something other than a data frame or matrix. I recommend also running class(addset) to see what type of object this really is.

ADD COMMENT
0
Entering edit mode

Hi jv,

Yes, it isn't a matrix. After running class(addset) it looks like this: enter image description here

ADD REPLY
0
Entering edit mode

A matrix and data.frame in R don't require rownames or colnames.

ADD REPLY

Login before adding your answer.

Traffic: 2659 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6