binomtest In R
0
0
Entering edit mode
5.3 years ago
Kai_Qi ▴ 130

Hello Everyone:

I have got a data frame after analyze my RNA seq data. Now I want to run a binomial test using data from two columns (eg, column Min and column Max, for example the first number of column Min will be used together with first number of column Max).

My code is binom.test(mydata_CRep1$Min, mydata_CRep1$Max, 1/3.5, alternative = "lower")

And it gives me error like

"Error in binom.test(mydata_CRep1$min..E1I..IE2...I._CRep1, mydata_CRep1$max..E1I...IE2...I.,  : 
  incorrect length of 'x'"

Can someone helps me figure out how should I write the code correctly?

Thanks,

Cai

R RNA-Seq • 1.9k views
ADD COMMENT
1
Entering edit mode

The error message is telling you that parameter x is not what the function is expecting. Have you checked that the data you're passing to the function corresponds to what it expects as written in the doc? If you want to iterate over rows of a data frame, you should use one of the functions of the apply family. Or maybe you're using the wrong test.

ADD REPLY
0
Entering edit mode

Thank you for your reply. I checked the columns and the number looks right. I also wrote a function to do it:

bt <- function(a, b, p=0.285){binom.test(a, b, 0.285, alternative = "less", conf.level = 0.95)}
mydata_CRep1$count_p_value_CRep1 <- mapply(bt, mydata_CRep1$min..E1I..IE2...I._CRep1, mydata_CRep1$max..E1I...IE2...I.)

the results is:

Error in binom.test(a, b, 0.285, alternative = "less", conf.level = 0.95) : 
  'n' must be a positive integer >= 'x'

What I followed is the paper : https://genome.cshlp.org/content/24/11/1774.full.pdf+html page 10 P-value(binomial{M = min(#E1I, #IE2, #I), N = min(#E1I, #IE2, #I) + max(#E1I, #IE2, #I), P = 1/3.5, alternative = lower }) $ 0.05

ADD REPLY

Login before adding your answer.

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