Poisson_Corrected_PCA {PoissonPCA} | R Documentation |
Estimates the principal components of the latent Poisson means (possibly with transformation) of high-dimensional data with independent Poisson measurement error.
Poisson_Corrected_PCA(X,k=dim(X)[2]-1,transformation=NULL,seqdepth=FALSE)
X |
Matrix or data frame of count variables |
k |
Number of principal components to calculate. |
transformation |
For estimating the principal components of a transformation of the Poisson mean. |
seqdepth |
Indicates what sort of sequencing depth correction should be used (if any). |
The options for the transformation parameter are:
NULL or "linear" - these perform no transformation.
"log" - this performs a logarithmic transformation
a list of the following functions:
f(x) - evaluates the function deriv(x) - evaluates the derivative of the function solvefunction(target) - evaluates the inverse of the function g(x) - an estimator for f(lambda) from a Poisson observation x with mean lambda CVar(x) - an estimator for the conditional variance of g(x) conditional on lambda from the observed value x
the function polynomial_transformation creates such a list in the case where f is a polynomial using unbiassed estimators for g and CVar. The function makelogtransformation creates an estimator for the logarithmic transformation. The "log" option uses this function with parameters a=3 and N=4, which from experiments appear to produce reasonable results in most situations.
The options for the seqdepth parameter are:
FALSE - indicating no sequencing depth correction
TRUE - indicating standard sequencing depth correction for linear PCA
"minvar" - uses the minimum covariance estimator for the corrected variance. This subtracts the largest constant from all entries of the matrix, such that the matrix is still non-negative definite.
"compositional" - uses the best compositional variance approximation to the estimated covariance matrix.
The package estimates latent principal components using the methods in http://arxiv.org/abs/1904.11745
An object of type "princomp" and "transformedprincomp" that has the following components:
sdev |
The standard deviation associated to each principal component |
loadings |
The principal component vectors |
center |
The mean of the transformed data |
scale |
A vector of ones of length n |
n.obs |
The number of observations |
scores |
The principal scores. For the linear transformation, these are just the projection of the data onto the principal component space. For transformed principal components, these use a combination of likelihood and mean squared error. |
means |
The corresponding estimated untransformed Poisson means. This provides a useful diagnostic of the performance in simulation studies. These means should be closer to the true Lambda than the original X data. |
variance |
The corrected covariance matrix for the transformed latent Sigma. |
non_compositional_variance |
The corrected covariance matrix without sequencing depth correction. |
call |
The function call used |
Toby Kenney tkenney@mathstat.dal.ca and Tianshu Huang
set.seed(12345) n<-20 #20 observations p<-5 #5 dimensions r<-2 #rank 2 mean<-10*c(1,3,2,1,1) Z<-rnorm(n*r) dim(Z)<-c(n,r) U<-rnorm(p*r) dim(U)<-c(r,p) Latent<-Z%*%U+rep(1,n)%*%t(mean) X<-rpois(n*p,as.vector(Latent)) dim(X)<-c(n,p) Poisson_Corrected_PCA(X,k=2,transformation=NULL,seqdepth=FALSE) seqdepth<-exp(rnorm(n)+2) Xseqdep<-rpois(n*p,as.vector(diag(seqdepth)%*%Latent)) dim(Xseqdep)<-c(n,p) Poisson_Corrected_PCA(Xseqdep,k=2,transformation=NULL,seqdepth=TRUE) squaretransform<-polynomial_transformation(c(1,0)) Xexp<-rpois(n*p,as.vector(diag(seqdepth)%*%exp(Latent))) Poisson_Corrected_PCA(Xseqdep,k=2,transformation="log",seqdepth="minvar")