Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can manually set your working directory in RStudio by selecting ‘Session' -> 'Set working directory' -> 'Choose directory' and then pointing it to the directory this script is in on your PC. This will output the 'setwd()’ command with your working directory into the console window (bottom left panel). Copy this command to replace the default one in the code below.

...

Code Block
####  Set your working directory ####

# **USER INPUT**
setwd("CH:/Users/whatmorp/OneDrive - Queensland University of Technology/Desktop/Manuscripts in progress/Fazeleh scRNA-Seq/New_analysis_scriptsam_dando/Pia_Choroid_dataset2/210913_A00401_0307_BHH3KJDRXY/HH3KJDRXY")

# You can see the sample subdirectories by:
list.dirs(full.names = F, recursive = F)
# You should see directories that are names after your samples. 
# If you don't see this, browse through your H or W drives to find the correct path for your sample directories.

Installing packages

Note: this section install several R packages and their dependencies. It will take several minutes to run.

Code Block
#### Installing required packages ####

# This section only needs to be run once on a computer. 
# One the packages are installed, they need to be loaded every time they will be used (next section)

# Create vector of required package names
bioconductor_packages <- c("clusterProfiler", "pathview", "AnnotationHub", "org.Mm.eg.db")
cran_packages <- c("Seurat", "patchwork", "ggplot2", "tidyverse", "viridis", "plyr", "readxl", "scales")

# Compares installed packages to above packages and returns a vector of missing packages
new_packages <- bioconductor_packages[!(bioconductor_packages %in% installed.packages()[,"Package"])]
new_cran_packages <- cran_packages[!(cran_packages %in% installed.packages()[,"Package"])]

# Install missing bioconductor packages
if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")
BiocManager::install(new_packages)

# Install missing cran packages
if (length(new_cran_packages)) install.packages(new_cran_packages, repos = "http://cran.us.r-project.org")

# Update all installed packages to the latest version
update.packages(bioconductor_packages, ask = FALSE)
update.packages(cran_packages, ask = FALSE, repos = "http://cran.us.r-project.org")

Loading packages

Code Block
#### Loading required packages ####

# This section needs to be run every time

# Load packages
bioconductor_packages <- c("clusterProfiler", "pathview", "AnnotationHub", "org.Mm.eg.db")
cran_packages <- c("Seurat", "patchwork", "ggplot2", "tidyverse", "viridis", "plyr", "readxl", "scales")
lapply(cran_packages, require, character.only = TRUE)
lapply(bioconductor_packages, require, character.only = TRUE)

 

Cell Ranger (and nfcore/scrnaseq) generates a default directory and file output structure for each sample, which we’ll use in R to complete our analysis. Each sample will have a directory named after the sample, an ‘outs’ subdirectory under this. This ‘outs’ directory contains various files and subdirectories. The subdirectory that contains the count matrix data we need for Seurat analysis is called ‘filtered_feature_bc_matrix’.

...