Skip to content

Latest commit

 

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ncww_mengyi

Analysis for Mengyi Dong's NC Wastewater project.

Project Structure

  • Rcode_Revised.Rmd — main analysis script
  • Data/ — input data files
  • Plots/ — folder where output figures are saved from running code

About renv

This project uses renv for package management. renv creates a project-local package library, meaning the packages installed for this project are isolated from your regular R library and won't interfere with your other work.

The renv.lock file records the version of every package used in this analysis, ensuring reproducible results.

Getting Started

Prerequisites

  • R and RStudio
    • R: This project requires R version 4.5 or later. Download R 4.5 from https://cran.r-project.org/. You can install R 4.5 alongside an existing R version without affecting other projects.
    • RStudio: Download the latest version from https://posit.co/download/rstudio-desktop/. RStudio must be compatible with R 4.5 — if you have an older RStudio installation, update it before proceeding.
  • Build tools (required for installing packages with compiled code, including phyloseq):
    • Mac: Check whether Xcode command line tools are installed by running the following in your Mac Terminal (not RStudio):
    xcode-select -p
If it returns a path (e.g. `/Library/Developer/CommandLineTools`), no further action is required. 
If you get an error, install with:
    xcode-select --install
  • Mac: Additionally, gfortran is required for installing certain packages (e.g. RcppArmadillo). Download and install gfortran for your Mac architecture from https://mac.r-project.org/tools/:

    • Apple Silicon (M1/M2/M3): select the arm64 version
    • Intel Mac: select the x86_64 version
  • Windows: Check whether Rtools is installed by running the following in the RStudio Console:

    install.packages("pkgbuild")
    pkgbuild::has_build_tools()
If it returns `FALSE`, download and install Rtools from: 
https://cran.r-project.org/bin/windows/Rtools/
  • renv package: Check to see if you have renv installed by running the following in your RStudio console:
  print(requireNamespace("renv", quietly = TRUE))

If it returns FALSE, install the package:

  install.packages("renv")

Clone repository, open project file, & restore environment

  1. Navigate to the repository on GitHub and copy the URL (click the green Code button and copy the HTTPS URL)
  2. In RStudio, go to File → New Project → Version Control → Git
  3. Paste the repository URL
  4. Set Project Directory Name to ncww_mengyi
  5. Choose a local directory and click Create Project
  • If you receive a “permission denied” pop-up, select OK. As long as you see the project displayed in the upper right corner of RStudio and the directory path in the bottom right corner, you may proceed. If the project did not open, open it by double-clicking ncww_mengyi.Rproj from your local folder.
  1. Verify R version by running the following in the RStudio Console:
  R.version$version.string
  • Note: R Version 4.5 or later is necessary for subsequent steps in order for renv to properly restore the environment with correct package versions. If you have multiple R versions installed and need to switch versions, do this via Tools → Project Options → R version (or Tools → Global Options → R version if Project Options do not have an R version option). Restart RStudio after switching.
  • If you are unable to use R 4.5 or later, skip the remaining steps in this section involving renv. You will need to manually install the correct package versions necessary for this project. See Additional Information listed in the last section of this README for the list of packages and their versions.
  1. Once you have verified you are running R 4.5 or later, activate the renv environment by running the following in the R Console:
renv::activate()
  1. Restore the package library by running the following in the R Console:
   renv::restore()

renv::restore() will install all required packages into the project-local library at the exact versions specified in renv.lock. The process may take 20-40 minutes the first time depending on your internet connection and machine. You only need to do this once when you first clone the repo. If you close and reopen the project, renv activates silently and uses the already-installed library.

Note: When running renv::restore() you may encounter the following prompts:

  • renv will list packages to be installed and ask you to confirm — type y and hit Enter to proceed
  • You may see a message about renv version mismatch (e.g. "renv 1.2.2 was loaded but project is configured to use renv 1.1.8") — this can be ignored, the restore will still work
  • Mac: If you encounter an error installing data.table mentioning 'libintl.h' file not found, you need to create a ~/.R/Makevars file. Run the following in your Mac Terminal:
  mkdir -p ~/.R
  echo 'CPPFLAGS += -DNOLIBINTL' >> ~/.R/Makevars

Then retry renv::restore() in RStudio.

  • Some packages are installed from Bioconductor rather than CRAN (e.g. phyloseq, DESeq2) — this is expected, follow the prompts to allow installation

  • Note on phyloseq: phyloseq is a Bioconductor package and should install automatically with renv::restore(). If it does not, install it manually by running:

renv::install("bioc::phyloseq")

IMPORTANT: After successfully completing renv::restore(), RStudio may display a banner at the top of the screen saying packages need to be installed. This can be ignored - Do NOT click Install on that banner. — This is a known RStudio behavior that occurs because renv installs packages into a project-local library rather than your global R library. To confirm packages installed correctly, try loading one in the Console:

library(phyloseq)

If no error appears, you may proceed to running the analysis.

Running the analysis

Open Rcode_Revised.Rmd in RStudio and run the file to produce results.

Note: The Plots/ subfolder is where output figures will be saved when you run the script.

Additional Information

Package List with Versions

| ape | 5.8-1 | | dplyr | 1.2.0 | | e1071 | 1.7-17 | | envalysis | 0.7.0 | | factoextra | 2.0.0 | | ggplot2 | 4.0.2 | | ggpubr | 0.6.3 | | ggrepel | 0.9.7 | | ggthemes | 5.2.0 | | here | 1.0.2 | | microbiome | 1.23.1 | | PathoStat | 1.36.0 | | pheatmap | 1.0.13 | | phyloseq | 1.54.2 | | pls | 2.7-3 | | RColorBrewer | 1.1-3 | | readxl | 1.4.5 | | renv | 1.1.8 | | rmarkdown | 2.30 | | scatterplot3d | 0.3-45 | | stats | 4.5.2 | | textshape | 1.7.5 | | tibble | 3.3.1 | | tidyr | 1.3.2 | | tools | 4.5.2 | | vegan | 2.7-3 |

About

Code for Mengyi Dong's NC Wastewater project.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages