install.packages(c("tidyverse", "factoextra", "knitr", "quarto", "ggpubr", "data.table"))
Programming resources
R
R programming language provides an extensive ecosystem for performing statistical analysis. If you are coming from the Python world, I am very sure you will hate the language at first. I hated it too. But as you dive deeper, you will form an unbreakable bond with the language.
Quick R primer
A notebook with some useful operations is available here.
Familiarizing yourself with R
To familiarize yourself with R, you can make use of the following two resources:
Recommended
- Swirl is an R learning package that will walk you through R programming language in a hands-on manner. Swirl will introduce and explore various topics in the form of interactive programming assignments within the Rstudio window. This is a completely free and open source package: https://swirlstats.com/students.html
- R for Data Science: learning R to analyze your data. “The goal of R for Data Science is to help you learn the most important tools in R that will allow you to do data science. After reading this book, you’ll have the tools to tackle a wide variety of data science challenges, using the best parts of R” https://r4ds.hadley.nz/
- We will make use of ggplot2 for our plotting needs
Installing R
Installing R on Windows OS
To install R on Windows OS:
Download the Windows executable from https://cran.r-project.org/bin/windows/base/ (Current is R-4.4.2: https://cran.r-project.org/bin/windows/base/R-4.4.2-win.exe)
Run the R executable file to start installation, and allow the app to make changes to your device.
Select the installation language.
Follow the installation instructions.
Click on “Finish” to exit the installation setup.
R has now been sucessfully installed on your Windows OS.
Installing R on MacOS X
Navigate to https://cran.r-project.org/bin/macosx/
If you have an Intel Mac, download the pkg file under “For older Intel Macs” or click here for direct download.
Alternatively, if you have Apple silicon M1/M2 Mac, download the pkg file under “For Apple silicon (M1/M2) Macs” or click here for direct download.
- Run the .pkg file, and follow the installation instructions similar to Steps 3 and beyond under the “Installing R on Windows” section
Installing R on Ubuntu
sudo apt-get install r-base r-recommended
Installing RStudio Desktop
Rstudio provides an easy-to-use graphical interface to run R.
Installing RStudio on MacOS X
Download RStudio Apple Image disk (.dmg) file using this link and run the .dmg.
Installing RStudio on Windows
Download Rstudio executable (.exe) file using this link and execute the .exe (accepting the defaults).
Installing Rstudio on Ubunutu
Download rstudio deb package based on your version:
To install (requires root):
sudo dpkg -i <rstudio.deb>
Install packages
We will also install a few R packages that we will need for analyzing our single-cell data. To install these packages, open RStudio and type the following lines of code in the subpanel titled “Console”:
Install quarto
We will also use Quarto to write most of our code, reports and assignments. The instructions on Quarto’s website are very comprehensive (choose the “Rstudio” option in Step 2).