Remove lines from a toptable that have an empty ID (symbol)
1
0
Entering edit mode
6.0 years ago
mannoulag1 ▴ 120

Hi,

How to remove lines (genes) from a toptable tt that have an empty ID (symbol)? These genes are not annotated and I would like to remove them from the toptable.

the columns are:

row.names, ID, logFC, AverExpr, …

Thanks

toptable limma R gene • 1.5k views
ADD COMMENT
0
Entering edit mode

What have you tried? This is a quite basic R question on slicing/subsetting a dataframe.

ADD REPLY
0
Entering edit mode

Basic R questions are more relevant to StackOverflow:

ADD REPLY
3
Entering edit mode
6.0 years ago
ahmad mousavi ▴ 800

Hi

notEmpty <- subset(tt, tt$ID !="")
ADD COMMENT
1
Entering edit mode

No need to call tt in subset again, try:

notEmpty <- subset(tt, ID != "")

Also note, from ?subset manual:

This is a convenience function intended for use interactively. For programming it is better to use the standard subsetting functions like [, and in particular the non-standard evaluation of argument subset can have unanticipated consequences.

So the preferred way would be:

notEmpty <- tt[ tt$ID != "", ]
ADD REPLY
0
Entering edit mode

yeah that's work too, nice code !!

ADD REPLY
0
Entering edit mode

thank you ahmad mousavi

ADD REPLY
0
Entering edit mode

If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.
Upvote|Bookmark|Accept

ADD REPLY

Login before adding your answer.

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