Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

126 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLAMP

GitHub issues Lifecycle: stable BiocCheck R-CMD-check

Bioconductor release status

Branch R CMD check Last updated
devel Bioconductor-devel Build Status
release Bioconductor-release Build Status

The goal of CLAMP (Curated Latent-variable Analysis with Molecular Priors) is to provide an easy-to-use package to extract interpretable latent variables from large transcriptomic datasets using biological priors.

Installation

You can install the latest release of CLAMP from Bioconductor:

if (!requireNamespace("BiocManager", quietly = TRUE)) {
    install.packages("BiocManager")
}

BiocManager::install("CLAMP")

If you want to test the development version, you can install it from the github repository:

BiocManager::install("chikinalab/CLAMP")

Now you can load the package using:

library(CLAMP)

Basic usage

Full documentation is available at chikinalab.org/CLAMP. For detailed instructions on how to use CLAMP, please see the vignette.

library(CLAMP)

set.seed(1)

# Load example dataset (genes × samples)
data("dataWholeBlood")

# CPM-normalize, filter low-expressed genes, log2 and z-score normalizations
dataWholeBlood_cpm <- cpmCLAMP(dataWholeBlood)

prep <- preprocessCLAMP(
    dataWholeBlood_cpm,
    mean_cutoff = 0.5,
    var_cutoff = 0.1
)

Y_z <- zscoreCLAMP(
    prep$Y_filtered,
    prep$rowStats
)

# Compute truncated SVD and select number of latent variables
svd_k <- select_svd_k(Y_z)

svd_res <- compute_svd(
    Y_z,
    k = svd_k
)

clamp_k <- select_clamp_k(
    svd_res,
    n_samples = ncol(Y_z),
    svd_k = svd_k
)

# Run CLAMPbase to initialize latent variables
baseRes <- CLAMPbase(
    Y = Y_z,
    svdres = svd_res,
    clamp_k = clamp_k
)

# Load pre-fetched gene set libraries bundled with the package
gmtList <- list(
    CellMarkers = readRDS(
        system.file("extdata", "CellMarker_2024.rds", package = "CLAMP")
    ),
    KEGG = readRDS(
        system.file("extdata", "KEGG_2021_Human.rds", package = "CLAMP")
    )
)

# Combine gene set libraries into a single sparse matrix
pathMatCell <- gmtListToSparseMat(gmtList)

# Load additional xCell reference matrix
data("xCell")

# Match pathways to the filtered gene space used by CLAMP
matchedPathsWB <- getMatchedPathwayMatList(
    pathMatCell,
    xCell,
    new.genes = rownames(Y_z),
    min.genes = 2
)

# Run CLAMPfull using CLAMPbase initialization and matched priors
fullRes <- CLAMPfull(
    Y = Y_z,
    priorMat = matchedPathsWB,
    clamp.base.result = baseRes,
    svdres = svd_res,
    clamp_k = clamp_k,
    use_cpp = TRUE
)

# Inspect outputs
dim(fullRes$Z)
dim(fullRes$B)
dim(fullRes$U)

# Inspect significant pathway annotations
summary_df <- as.data.frame(fullRes$summary)

sig_summary <- summary_df[
    summary_df$FDR < 0.05 & summary_df$AUC > 0.7,
    c("LV", "pathway", "FDR", "AUC")
]

sig_summary <- sig_summary[order(sig_summary$FDR), ]

head(sig_summary, 20)

Code of Conduct

Please note that the CLAMP project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages