R/estP.R

Defines functions nb_pvalue_store myDnbinomR generateA2FxR

#' @useDynLib RnaSeqSampleSize generateA2Fx myDnbinom2
#' @importFrom Rcpp sourceCpp
#' @importFrom KEGGREST keggLink
#' @importFrom grDevices rainbow
#' @importFrom graphics abline legend lines points polygon
#' @importFrom stats dnbinom lm pnbinom qbeta qnbinom qnorm
#' @importFrom utils data flush.console
#' @importFrom methods is
#' 
generateA2FxR <- function(a,n,phi)
	.Call("generateA2Fx",as.double(a),as.double(n),as.double(phi),PACKAGE="RnaSeqSampleSize")

myDnbinomR <- function(a, mu,size,a2Fx)
	.Call("myDnbinom2",as.double(a),as.double(mu),as.double(size),as.double(a2Fx[a+1]),PACKAGE="RnaSeqSampleSize")

nb_pvalue_store<-function(X1X0Sum, n, phi, w=1,k=1,a2Fx=NULL) {
	a<-0:X1X0Sum
	weight<-k*w/(k*w+1)
	if(w==1 && k==1){
		azanom<-myDnbinomR(a, mu=X1X0Sum/2, size=n/phi,a2Fx=a2Fx)
#		anom<-dnbinom(a, mu=(X1X0Sum/2), size=n/phi)
#		zanom<-rev(anom)
#		azanom<-anom * zanom
	}else{
		anom<-dnbinom(a, mu=X1X0Sum*(weight), size=n*k/phi)
		zanom<-dnbinom(X1X0Sum-a, mu=X1X0Sum*(1-weight),size=n/phi)
		azanom<-anom * zanom
	}
	yy<-azanom/sum(azanom)
	return(yy)
}

Try the RnaSeqSampleSize package in your browser

Any scripts or data that you put into this service are public.

RnaSeqSampleSize documentation built on Nov. 8, 2020, 6:54 p.m.