ucsf-ferguson-lab / syndRomics

R syndRomics package
MIT License
5 stars 2 forks source link

CI for loadings and communalities plots not positioned properly #6

Closed tk27182 closed 3 years ago

tk27182 commented 3 years ago

I've been playing with this package using the Ionosphere dataset and when I get to plotting the standardized loadings and communalities with barmaps, the confidence intervals are not located at the tips of the bars but seem to randomly be displaced.

The code I've written to produce the plots is below:

library(syndRomics)
library(ggplot2)
library(dplyr)
library(stringr)
library(mlbench)

# Load Johns Hopkins University Ionosphere dataset
data(Ionosphere)

# Remove columns for classification or that only have 1 unique value
idf <- Ionosphere[, !(names(Ionosphere) %in% c("V2", "Class"))]

# Create PCA
ipca_data <- as.matrix(apply(idf, 2, as.numeric))
ipca <- prcomp(ipca_data, center = T, scale. = T)

# Extract standardized loadings
iloadings <- stand_loadings(ipca, ipca_data)

# Permute and keep components
set.seed(500)
P <- 500
ndim <- 5
iper <- permut_pc_test(ipca, ipca_data, P = P, ndim = ndim, statistic = "VAF")

# Component Interpretation
is_per <- permut_pc_test(ipca, ipca_data, P=P, ndim=ndim, statistic='s.loadings', perm.method = 'permV')

# Component stability
ibooted_PCA <- pc_stability(ipca, ipca_data, ndim = ndim, B = P, similarity_metric = 'all')

# Plot loadings and CI
show(plot(ibooted_PCA, plot_resample = T))

# Plot communalities & CI
show(plot(ibooted_PCA, communalities = T, plot_resample = T))

iono_loadings iono_commun

Is there some way I can adjust the positions of the CI's?

ATEspin commented 3 years ago

There is a bug in the code that organizes the variables. I have a solution that is working. I will release a new version of the package soon as I get other bugs fixed.

Thanks!

ATEspin commented 3 years ago

pushed the fix