how to get name column having more number of gene occurrence
1
0
Entering edit mode
6.8 years ago
Kritika ▴ 260

Hello All i have file for example like this:

s1 s2 s3 s4 s5 s6 
x   y   a   q   a  h
h   b   a   h   a  q
a   c   v   b   n  k
b   c   a

assuming a,b,c,d,e,f is my genes name

so as can be seen x is only present in one sample so i can say x is present in 16.6% population only present in s1

so i need some R code or some other way i can do?

Gene Occurence Column • 1.3k views
ADD COMMENT
0
Entering edit mode
6.8 years ago
Chirag Parsania ★ 2.0k

Hi,

Input data

s1  s2  s3  s4  s5  s6
x   y   x   q   a   h
h   b   a   h   a   q
a   c   v   b   n   k
b   c   a   h   x   a

this may help

library("psych")

dat <- read.clipboard(header = T)
dat <- as.matrix(dat)

out_prcnt <- apply(dat,1, function(elem){

        fq <- table(elem)
        prcnt = fq/sum(fq) * 100
        return(prcnt)
})
ADD COMMENT

Login before adding your answer.

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