How to remove entire rows from seurat object based on cellhash read
1
0
Entering edit mode
5.2 years ago
cook.675 ▴ 230

Heres the last 3 columns of metadata from my seurat object (pbs.hashtag):

                 hash.ID  percent.mt  stim
AAACCCAAGGAGAGGC    htag2   4.786380  VEH
AAACCCAAGTCTCTGA    htag3   6.642512  VEH
AAACCCAAGTTTCAGC  Doublet   2.559588  VEH
AAACCCACACAGTCAT Negative   4.982733  VEH
AAACCCACACGCGCAT    htag2   3.220281  VEH
AAACCCACACGGATCC    htag2   3.391841  VEH

I want to remove all rows from the object that have Doublet as the hash ID. Here's what I tried:

pbs.hashtag <- subset(pbs.hashtag, subset = meta.data@hash.ID != "Doublet")

it didn't work obvioulsy it says:

Error in FetchData(object = object, vars = expr.char[vars.use], cells = cells, : None of the requested variables were found:

Any ideas? I also tried meta.data$hash.ID in the subset line. Im pretty new to R and Seurat but I used to program some C 20 years ago so im getting back in the pool.

thanks!

seurat • 10k views
ADD COMMENT
0
Entering edit mode

Hello,

could you please explain how how to get this doublet tag in the metadata?

thanks in advance!

Tushar

ADD REPLY
0
Entering edit mode

Hi there,

I tried to remove certain rows in my dataset as well using this function.

                                   Sample donor organ sort method file is.TRA.p is.TRB.p is.TRA.np

FCAImmP7179369-AAACGGGTCTGTCAAG      6     3     0    1      0    2    FALSE    FALSE     FALSE
FCAImmP7179369-AAATGCCAGCTTATCG      6     3     0    1      0    2    FALSE    FALSE     FALSE
FCAImmP7179369-AACTCAGTCATTGCGA      6     3     0    1      0    2    FALSE    FALSE     FALSE
FCAImmP7179369-AAGCCGCAGTGTCCCG      6     3     0    1      0    2    FALSE    FALSE     FALSE
FCAImmP7179369-AAGTCTGCACAGCCCA      6     3     0    1      0    2    FALSE    FALSE     FALSE
FCAImmP7179369-ACACCGGGTTCCACGG      6     3     0    1      0    2    FALSE    FALSE     FALSE

To clarify, I would like to remove all rows with Sample number 30 and 31 with the following code:

treg <- subset(treg, subset = Sample != c("30", "31"))

When I type in dim(treg) and look at the dimensions, it seems to have worked as I seem to have removed 44 cells by doing this. However, when I type View(treg@meta.data) and scroll down, I still see the cells that I wanted to have removed in my data frame. Am I doing something wrong? Is there a way to double check whether I have performed this properly? Why are my unwanted rows still present in my meta.data?

Many thanks in advance, Florencia

ADD REPLY
4
Entering edit mode
5.2 years ago
cook.675 ▴ 230

Guys I got it! DUHHHH

pbs.hashtag <- subset(pbs.hashtag, subset = hash.ID != "Doublet")
ADD COMMENT

Login before adding your answer.

Traffic: 1807 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