knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Below is a demo of installing and running SJD package on simulated datasets. For analytical vignette using real data, please refer to Real Data Analysis here.
SJD
packageTo install this package in R, run the following commands:
library(devtools) install_github("CHuanSite/SJD")
library(SJD)
# Simulation the dataset dataset = list(matrix(runif(5000, 1, 2), nrow = 100, ncol = 50), matrix(runif(5000, 1, 2), nrow = 100, ncol = 50), matrix(runif(5000, 1, 2), nrow = 100, ncol = 50), matrix(runif(5000, 1, 2), nrow = 100, ncol = 50)) ## Specify the structure among the datasets group = list(c(1,2,3,4), c(1,2), c(3,4), c(1,3), c(2,4), c(1), c(2), c(3), c(4)) comp_num = c(2,2,2,2,2,2,2,2,2) ## Separate PCA, ICA, NMF sepPCA_res = sepPCA(dataset, comp_num) sepICA_res = sepICA(dataset, comp_num) sepNMF_res = sepNMF(dataset, comp_num) ## Concatenated PCA, ICA, NMF concatPCA_res = concatPCA(dataset, group, comp_num) concatICA_res = concatICA(dataset, group, comp_num) concatNMF_res = concatNMF(dataset, group, comp_num) ## Joint PCA, ICA, NMF jointPCA_res = jointPCA(dataset, group, comp_num) jointICA_res = jointICA(dataset, group, comp_num) jointNMF_res = jointNMF(dataset, group, comp_num) ## twoStageLCA twoStageLCA_res = twoStageLCA(dataset, group, comp_num)
To access the component
str(concatPCA_res$linked_component_list)
To access the score
str(concatPCA_res$score_list)
SJD package also allows users to specify weights for datasets during the analysis
# Simulation the dataset dataset = list(matrix(runif(5000, 1, 2), nrow = 100, ncol = 50), matrix(runif(5000, 1, 2), nrow = 100, ncol = 50), matrix(runif(5000, 1, 2), nrow = 100, ncol = 50), matrix(runif(5000, 1, 2), nrow = 100, ncol = 50)) ## Specify the structure among the datasets group = list(c(1,2,3,4), c(1,2), c(3,4), c(1,3), c(2,4), c(1), c(2), c(3), c(4)) comp_num = c(2,2,2,2,2,2,2,2,2) weighting = c(2, 1, 4, 3) ## Separate PCA, ICA, NMF sepPCA_res = sepPCA(dataset, comp_num, weighting) sepICA_res = sepICA(dataset, comp_num, weighting) sepNMF_res = sepNMF(dataset, comp_num, weighting) ## Concatenated PCA, ICA, NMF concatPCA_res = concatPCA(dataset, group, comp_num, weighting) concatICA_res = concatICA(dataset, group, comp_num, weighting) concatNMF_res = concatNMF(dataset, group, comp_num, weighting) ## Joint PCA, ICA, NMF jointPCA_res = jointPCA(dataset, group, comp_num, weighting) jointICA_res = jointICA(dataset, group, comp_num, weighting) jointNMF_res = jointNMF(dataset, group, comp_num, weighting) ## twoStageLCA twoStageLCA_res = twoStageLCA(dataset, group, comp_num, weighting)
# Simulation the dataset dataset = list(matrix(runif(5000, 1, 2), nrow = 100, ncol = 50), matrix(runif(5000, 1, 2), nrow = 100, ncol = 50), matrix(runif(5000, 1, 2), nrow = 100, ncol = 50), matrix(runif(5000, 1, 2), nrow = 100, ncol = 50)) ## Specify the structure among the datasets group = list(c(1,2,3,4), c(1,2), c(3,4), c(1,3), c(2,4), c(1), c(2), c(3), c(4)) comp_num = c(2,2,2,2,2,2,2,2,2) ## Projected new data sets proj_dataset = list(matrix(runif(5000, 1, 2), nrow = 100, ncol = 50)) proj_group = list(c(TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE)) ## concatenate PCA with projection functionality on res_concatPCA = concatPCA(dataset, group, comp_num, weighting = NULL, proj_dataset = proj_dataset, proj_group = proj_group)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.