plotPcorvsCor {CoNI} | R Documentation |
Correlation vs Partial correlation
Description
This function fits two linear models on standardize data and plots the results. It generates a scatter plot with two regression lines, where the slopes correspond to the correlation and partial correlation coefficients (blue for cor and red for pcor)
Usage
plotPcorvsCor(
ResultsCoNI,
edgeFeature,
vertexD,
edgeD,
vertexFeatures = NULL,
outputDir = "./",
fname,
label_edgeFeature = "Edge Feature",
plot_to_screen = TRUE,
height = 10,
width = 8,
saveFiles = FALSE
)
Arguments
ResultsCoNI |
The significant results generated by CoNI |
edgeFeature |
The edge feature to explore e.g. Fabp2 (for a gene) |
vertexD |
Vertex data that was given as input to CoNI |
edgeD |
Edge data that was given as input to CoNI |
vertexFeatures |
The vertex features to include as a list. If not specified all metabolites available in combination with the edgeFeature will be used |
outputDir |
Output directory with path |
fname |
File name to save the plots |
label_edgeFeature |
Name for plot title e.g. Gene or Protein |
plot_to_screen |
logical. If TRUE plots will be outputted to the plotting screen |
height |
height of the plotting area for the saved file |
width |
width of the plotting are for the saved file |
saveFiles |
logical. If FALSE plot is not saved to disk |
Value
Returns a ggplot object for a scatter plot with two regression lines. The blue line is the regression of the vertex features, and the red line is the regression of the resulting residuals after regressing each vertex feature with the edge feature. The slope of the blue line corresponds to the pearson correlation coefficient and the slope of the red line to the partial correlation coefficient
Examples
#Load gene expression - Toy dataset of two treatments
data(GeneExpToy)
#Samples in rows and genes in columns
GeneExp <- as.data.frame(t(GeneExpToy))
hfd_gene <- GeneExp[1:8,] #high fat diet
chow_gene<- GeneExp[9:nrow(GeneExp),] #chow diet
#Load metabolite expression - Toy dataset of two treatments
data(MetaboExpToy)
MetaboExp <- MetaboExpToy
hfd_metabo <- MetaboExp[11:18,] #high fat diet
chow_metabo <- MetaboExp[1:10,] #chow diet
#Match row names both data sets
rownames(hfd_metabo)<-rownames(hfd_gene)
rownames(chow_metabo)<-rownames(chow_gene)
#Load CoNI results
data(CoNIResultsHFDToy)
plotPcorvsCor(ResultsCoNI = CoNIResultsHFDToy,
edgeFeature = "Arfrp1",
vertexFeatures = c("PC.ae.C40.2", "SM..OH..C22.1"),
vertexD = hfd_metabo,
edgeD = hfd_gene,
label_edgeFeature = "Gene",
plot_to_screen = TRUE,
height = 10,
saveFiles = FALSE)