[R] Help, how to find the genes with A<19?
arun
smartpink111 at yahoo.com
Sat May 4 18:46:32 CEST 2013
Hi,
lst1<-apply(dat1,1,table)
res<-which(unlist(lapply(lst1,function(x) {indx<-names(x)%in%"A"; if(any(indx)) x[indx]<19 else NA}),use.names=FALSE))
head(res)
#[1] 19 39 40 41 43 45
length(res)
#[1] 1481
lst1[c(19,39,40)]
#$`19`
#
# A P
# 1 37
#
#$`39`
#
# A P
#12 26
#
#$`40`
#
# A P
#16 22
#rows without "A"
res1<-unlist(lapply(lst1,function(x) {indx<-names(x)%in%"A"; if(any(indx)) x[indx]<19 else NA}),use.names=FALSE)
resNoA<-which(is.na(res1))
head(resNoA)
#[1] 38 42 44 47 67 89
lst1[c(38,42)]
#$`38`
#
# P
#38
#
#$`42`
#
# M P
# 1 37
dat1[38,]
# call call.1 call.2 call.3 call.4 call.5 call.6 call.7 call.8 call.9 call.10
#38 P P P P P P P P P P P
# call.11 call.12 call.13 call.14 call.15 call.16 call.17 call.18 call.19
#38 P P P P P P P P P
# call.20 call.21 call.22 call.23 call.24 call.25 call.26 call.27 call.28
#38 P P P P P P P P P
# call.29 call.30 call.31 call.32 call.33 call.34 call.35 call.36 call.37
#38 P P P P P P P P P
A.K.
>Thank you for your help
>
>But what I mean is that, for example, in row 1 (gene1), dat1[1,], there are 38 As in this row.
>What I want to find is in these 7129 rows, in how many (which) rows, that there are no more than 18 As within one row.
>Or should I say, the count for the character "A" is no more than 18 in one row.
>
>Thanks
----- Original Message -----
From: arun <smartpink111 at yahoo.com>
To: R help <r-help at r-project.org>
Cc:
Sent: Saturday, May 4, 2013 11:43 AM
Subject: Re: Help, how to find the genes with A<19?
Hi,
If it is to get the first 18 genes (based on rownumbers)
dat1<- read.table("apcall.txt",header=TRUE,sep="",stringsAsFactors=FALSE)
dat1[1:18,]
#or
dat1[as.numeric(rownames(dat1))<19,]
A.K.
>The row numbers represent 7129 different genes
>The 38 columns represent 38 different patients
>How can I find the genes with A number < 19 in these 7129 genes?
>I have searched and tried for 7 hours but still can not find the way to solve
apcall.txt
More information about the R-help
mailing list