Skip to content

Instantly share code, notes, and snippets.

@loukesio
Last active December 17, 2025 17:10
Show Gist options
  • Select an option

  • Save loukesio/7b17b926a177752f890d28c24ae33d5d to your computer and use it in GitHub Desktop.

Select an option

Save loukesio/7b17b926a177752f890d28c24ae33d5d to your computer and use it in GitHub Desktop.
R Package Installation Guide - Data Visualization and Genomics Course
# ============================================================================
# R Package Installation Guide
# Data Visualization and Genomics Course
# ============================================================================
#
# This script will help you install all required R packages for the course.
#
# Prerequisites:
# - R version: 4.3.0 or higher (recommended: 4.4.0+)
# - RStudio: Latest version recommended
# - Internet connection: Required for package downloads
#
# Check your R version:
# R.version.string
#
# ============================================================================
# ============================================================================
# STEP 1: Install CRAN Packages
# ============================================================================
#
# Copy and paste this into your R console.
# ⏱️ This will take 10-20 minutes depending on your internet speed.
# List of CRAN packages
cran_packages <- c(
"DataExplorer", "UpSetR", "VennDiagram", "GGally", "MetBrewer",
"RColorBrewer", "ape", "colorspace", "cowplot", "dplyr",
"ggcorrplot", "ggforce", "gghighlight", "ggplot2", "ggplotify",
"ggpubr", "ggrepel", "grid", "gtools", "patchwork", "plotly",
"scales", "showtext", "skimr", "tidyverse", "viridis", "qqman"
)
# Install packages
install.packages(cran_packages, dependencies = TRUE)
# ============================================================================
# STEP 2: Install Bioconductor Packages
# ============================================================================
#
# ⏱️ This will take 5-10 minutes.
# Install BiocManager if not already installed
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
# List of Bioconductor packages
bioc_packages <- c(
"Biostrings", "ComplexHeatmap", "DECIPHER",
"circlize", "genoPlotR", "msa", "pwalign", "seqinr"
)
# Install Bioconductor packages
BiocManager::install(bioc_packages, update = FALSE)
# ============================================================================
# STEP 3: Install Course-Specific Packages
# ============================================================================
#
# These are custom packages developed for genomics visualization
# Install devtools if not already installed
if (!require("devtools", quietly = TRUE))
install.packages("devtools")
# Install ggvolc (volcano plot visualization)
devtools::install_github("loukesio/ggvolc")
# Install ltc (custom package)
devtools::install_github("loukesio/ltc")
# ============================================================================
# VERIFY INSTALLATION
# ============================================================================
#
# After installation, verify that all packages are working
# Check CRAN packages
cran_check <- c(
"DataExplorer", "UpSetR", "VennDiagram", "GGally", "MetBrewer",
"RColorBrewer", "ape", "colorspace", "cowplot", "dplyr",
"ggcorrplot", "ggforce", "gghighlight", "ggplot2", "ggplotify",
"ggpubr", "ggrepel", "grid", "gtools", "patchwork", "plotly",
"scales", "showtext", "skimr", "tidyverse", "viridis", "qqman"
)
# Check Bioconductor packages
bioc_check <- c(
"Biostrings", "ComplexHeatmap", "DECIPHER",
"circlize", "genoPlotR", "msa", "pwalign", "seqinr"
)
# Check custom packages
custom_check <- c("ggvolc", "ltc")
# Run verification
all_packages <- c(cran_check, bioc_check, custom_check)
missing_packages <- all_packages[!sapply(all_packages, require, character.only = TRUE, quietly = TRUE)]
if (length(missing_packages) == 0) {
cat("✅ All packages installed successfully!\n")
} else {
cat("❌ The following packages failed to install:\n")
print(missing_packages)
}
# ============================================================================
# TROUBLESHOOTING
# ============================================================================
#
# Issue 1: Package installation fails
# Error: installation of package 'X' had non-zero exit status
#
# Solution:
# - Update R to the latest version
# - Update all existing packages: update.packages(ask = FALSE)
# - Try installing the problematic package individually
#
# On macOS: Install Xcode Command Line Tools
# Open Terminal and run: xcode-select --install
#
# On Linux: Install development libraries
# Open Terminal and run:
# sudo apt-get install libcurl4-openssl-dev libssl-dev libxml2-dev
#
# ----------------------------------------------------------------------------
#
# Issue 2: Bioconductor packages not installing
#
# Solution:
# install.packages("BiocManager")
# BiocManager::install(version = "3.18")
# BiocManager::install(bioc_packages)
#
# ----------------------------------------------------------------------------
#
# Issue 3: GitHub packages (ggvolc, ltc) not installing
#
# Solution:
# usethis::create_github_token()
# gitcreds::gitcreds_set()
# devtools::install_github("loukesio/ggvolc", force = TRUE)
# devtools::install_github("loukesio/ltc_palettes", force = TRUE)
# ----------------------------------------------------------------------------
#
# Issue 4: Compilation errors on Windows
#
# Solution:
# - Install Rtools: https://cran.r-project.org/bin/windows/Rtools/
# - Make sure Rtools is on your PATH
# - Restart RStudio after installation
#
# ============================================================================
# ============================================================================
# NEXT STEPS
# ============================================================================
#
# Once all packages are installed:
# 1. Open the first course notebook
# 2. Run the setup chunk to load libraries
# 3. Start learning! 🎉
#
# Last updated: December 2025
# ============================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment