This function will calculate the pcs using prcomp function, and correlate categorical and numerical variables from metadata.
degCovariates(counts, metadata, fdr = 0.1, scale = FALSE, minPC = 5, correlation = "kendall", addCovDen = TRUE, plot = TRUE)
counts | normalized counts matrix |
---|---|
metadata | data.frame with samples metadata. |
fdr | numeric value to use as cutoff to determine the minimum fdr to consider significant correlations between pcs and covariates. |
scale | boolean to determine wether counts matrix should be scaled for pca. default FALSE. |
minPC | numeric value that will be used as cutoff to select only pcs that explain more variability than this. |
correlation | character determining the method for the correlation between pcs and covariates. |
addCovDen | boolean. Whether to add the covariates
dendograme to the plot to see covariates relationship.
It will show |
plot | Whether to plot or not the correlation matrix. |
: list: a) significantCovars, covariates with FDR below the cutoff. b) plot, heatmap of the correlation found. * means pvalue < 0.05. Only variables with FDR value lower than the cutoff are colored. c) corMatrix, correlation, p-value, FDR values for each covariate and PCA pais d) effectsSignificantcovars: that is PCs correlation between covariate and PCs, e) pcsMatrix: PCs loading for each sample
data(humanGender) library(DESeq2) idx <- c(1:10, 75:85) dse <- DESeqDataSetFromMatrix(assays(humanGender)[[1]][1:1000, idx], colData(humanGender)[idx,], design=~group) res <- degCovariates(log2(counts(dse)+0.5), colData(dse))#> #>#> #> #>res$plotres$scatterPlot[[1]]