CraftGRN CraftGRN logo

Introduction

CraftGRN is a modular framework for integrating chromatin accessibility profiles from ATAC-seq with matched RNA-seq expression data to infer condition-specific transcription factor binding sites and reconstruct dynamic gene regulatory networks.

CraftGRN helps users:

CraftGRN pipeline

Installation

CraftGRN can be installed from GitHub:

# Using remotes
# remotes::install_github("oncologylab/craftgrn")
install.packages("craftgrn", repos = c('https://oncologylab.r-universe.dev', 'https://cloud.r-project.org'))

# or using pak
pak::pak("oncologylab/craftgrn")

Common CRAN and Bioconductor dependencies can be installed with:

install.packages(c("igraph", "ggplot2", "data.table", "BiocManager"))
BiocManager::install(c("DESeq2", "GenomicRanges", "SummarizedExperiment"))

Demo Data

CraftGRN keeps demo datasets outside the source package so installation remains small and CRAN-friendly. The package helper reports any configured external demo bundles:

craftgrn::craftgrn_demo_data_info()

No external demo bundle is currently configured. To run your own project, point CraftGRN at a project-level YAML file:

config <- "project.yaml"
module1_dir <- file.path(tempdir(), "predict_tf_binding_sites")

omics <- craftgrn::load_prep_multiomic_data(
  config = config,
  label_col = "strict_match_rna",
  do_preprocess = FALSE,
  verbose = TRUE
)

module1 <- craftgrn::predict_tfbs(
  omics_data = omics,
  out_dir = module1_dir,
  output_format = "auto",
  write_outputs = TRUE,
  write_stats = FALSE,
  verbose = TRUE
)

Troubleshooting:

Pipeline Overview

CraftGRN is organized as a three-module workflow.

Module 1: Predict TF Binding Sites

Module 1 loads matched ATAC, RNA, metadata, and optional footprint score files, then prepares a multiomic data object for downstream regulatory analysis.

Primary package functions:

Module 1 workflow

Module 2: Connect TFs to Target Genes

Module 2 links TF binding sites to candidate target genes using enhancer-gene maps, genomic distance windows, or 3D chromatin interaction priors. Candidate TF->TFBS->target links are filtered by condition-specific expression, binding, footprint or peak signal, and cross-condition correlation evidence.

Primary package functions:

Module 2 workflow

Module 3: Learn Regulatory Topics and Visualize Differential GRNs

Module 3 compares condition-specific regulatory links, builds joint RNA and footprint document-term matrices, trains topic models, assigns regulatory links to topics, and summarizes pathway and master TF programs.

Primary package functions:

For regular package runs, keep one selected Module 3 setup in project.yaml, for example:

topic_method: comparison_aggr_multivi
topic_k: 10
warplda_iterations: 2000
topic_link_output: pass
topic_term_assignment_method: gammafit_maxprob
topic_gammafit_thrP:
  lda: 0.70
  multivi: 0.50
pathway_backend: enrichly
pathway_species: human_mouse_best

topic_benchmark_enabled: false
topic_benchmark_methods: []
topic_benchmark_k_grid: []

Module 3 uses different evidence for different topic-assignment units:

pathway_backend: enrichly uses local cached pathway libraries when the optional enrichly package is installed; pathway_backend: enrichr keeps the web API backend. Set pathway_species: human, pathway_species: mouse, or pathway_species: human_mouse_best to choose pathway database behavior; if omitted, Module 3 infers the species from ref_genome when possible. Benchmark grids are optional and should be enabled only for method-comparison experiments.

For cross-species projects or mouse data where human pathway libraries remain biologically useful, set pathway_species: human_mouse_best. Module 3 runs the human and mouse pathway database sets separately, writes the full audit table, and reports one best row per topic and normalized pathway name. The selected row is ranked by adjusted p-value, then logp, combined score, and overlap size, while retaining the selected species and database columns.

Pathway gene matching uses formal species-specific gene-symbol resolution when the relevant Bioconductor organism package is installed: org.Hs.eg.db for human and org.Mm.eg.db for mouse. CraftGRN resolves official symbols, case-insensitive symbols, aliases, ENSEMBL IDs, and ENTREZ IDs before comparing pathway inputs and returned overlap genes. If no formal match is available, it keeps a deterministic case-normalized fallback so old all-uppercase versus titlecase differences still match where possible.

Standard extraction folders are flat. For a selected K, review the K root for topic_terms.csv, topic_gene_peak_assignment.csv, topic_term_assignment_summary.csv, topic_links_pass.csv, topic_item_coverage_counts.csv, topic_terms_and_cutoffs_summary.pdf, topic_term_phi_score_heatmap_K*.pdf, topic_pathway_enrichment_dotplot.pdf, and per_comparison_topic_pathway_enrichment.csv. Standard runs do not create LDAvis, doc-topic heatmap, raw-theta document heatmap, topic pathway heatmap, standalone topic-term score heatmap, nested TF assignment, nested term assignment, or nested per-comparison pathway folders.

Module 3 workflow

Get Started

For a module-by-module tutorial, see the Get started article.

Documentation

Citation

Li, Y., Yi, C. et al. (in preparation). CraftGRN: Integrative ATAC-RNA framework for condition-specific gene regulatory network analysis.

License

This project is licensed under the GNU General Public License v3.0.