Question: how to get name column having more number of gene occurrence
0
gravatar for Kritika
3.4 years ago by
Kritika260
India
Kritika260 wrote:

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?

column occurence gene • 767 views
ADD COMMENTlink modified 3.4 years ago by Chirag Parsania1.9k • written 3.4 years ago by Kritika260
0
gravatar for Chirag Parsania
3.4 years ago by
Chirag Parsania1.9k
University of Macau
Chirag Parsania1.9k wrote:

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 COMMENTlink modified 3.4 years ago • written 3.4 years ago by Chirag Parsania1.9k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1366 users visited in the last hour