From fc7c9d84840265625066f1ef8fc74d5ea97f004f Mon Sep 17 00:00:00 2001 From: Kent Riemondy Date: Mon, 6 Nov 2023 10:17:56 -0700 Subject: [PATCH] update r install and other clean up --- .gitignore | 3 +- .../img/install-packages.png | Bin .../img/tidy-load.png | Bin .../img/tily-load.png | Bin .../install-r.Rmd | 81 ++++++---- .../install-r.html | 148 +++++++++++------- .../anchor-4.2.2/anchor.min.js | 0 .../bowser-1.9.3/bowser.min.js | 0 .../distill-2.2.21/template.v2.js | 0 .../header-attrs-2.14/header-attrs.js | 0 .../header-attrs-2.25/header-attrs.js | 12 ++ .../jquery-3.6.0/jquery-3.6.0.js | 0 .../jquery-3.6.0/jquery-3.6.0.min.js | 0 .../jquery-3.6.0/jquery-3.6.0.min.map | 0 .../popper-2.6.0/popper.min.js | 0 .../tippy-6.2.7/tippy-bundle.umd.min.js | 0 .../tippy-6.2.7/tippy-light-border.css | 0 .../install-r_files/tippy-6.2.7/tippy.css | 0 .../tippy-6.2.7/tippy.umd.min.js | 0 .../webcomponents-2.0.0/webcomponents.js | 0 classes.Rmd | 14 +- ex/prerequisite.Rmd | 16 +- index.Rmd | 6 +- schedule.Rmd | 47 +++--- 24 files changed, 198 insertions(+), 129 deletions(-) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/img/install-packages.png (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/img/tidy-load.png (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/img/tily-load.png (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r.Rmd (55%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r.html (85%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/anchor-4.2.2/anchor.min.js (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/bowser-1.9.3/bowser.min.js (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/distill-2.2.21/template.v2.js (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/header-attrs-2.14/header-attrs.js (100%) create mode 100644 _posts/2023-11-06-install-r/install-r_files/header-attrs-2.25/header-attrs.js rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/jquery-3.6.0/jquery-3.6.0.js (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/jquery-3.6.0/jquery-3.6.0.min.js (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/jquery-3.6.0/jquery-3.6.0.min.map (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/popper-2.6.0/popper.min.js (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/tippy-6.2.7/tippy-bundle.umd.min.js (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/tippy-6.2.7/tippy-light-border.css (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/tippy-6.2.7/tippy.css (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/tippy-6.2.7/tippy.umd.min.js (100%) rename _posts/{2022-10-03-install-r => 2023-11-06-install-r}/install-r_files/webcomponents-2.0.0/webcomponents.js (100%) diff --git a/.gitignore b/.gitignore index e43c31f..c15031e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ *.gz docs .Rhistory -ex/problem-set-3/matrices_clustering_heatmaps_key.* \ No newline at end of file +ex/problem-set-3/matrices_clustering_heatmaps_key.* +ps diff --git a/_posts/2022-10-03-install-r/img/install-packages.png b/_posts/2023-11-06-install-r/img/install-packages.png similarity index 100% rename from _posts/2022-10-03-install-r/img/install-packages.png rename to _posts/2023-11-06-install-r/img/install-packages.png diff --git a/_posts/2022-10-03-install-r/img/tidy-load.png b/_posts/2023-11-06-install-r/img/tidy-load.png similarity index 100% rename from _posts/2022-10-03-install-r/img/tidy-load.png rename to _posts/2023-11-06-install-r/img/tidy-load.png diff --git a/_posts/2022-10-03-install-r/img/tily-load.png b/_posts/2023-11-06-install-r/img/tily-load.png similarity index 100% rename from _posts/2022-10-03-install-r/img/tily-load.png rename to _posts/2023-11-06-install-r/img/tily-load.png diff --git a/_posts/2022-10-03-install-r/install-r.Rmd b/_posts/2023-11-06-install-r/install-r.Rmd similarity index 55% rename from _posts/2022-10-03-install-r/install-r.Rmd rename to _posts/2023-11-06-install-r/install-r.Rmd index 9f97bcf..e161afe 100644 --- a/_posts/2022-10-03-install-r/install-r.Rmd +++ b/_posts/2023-11-06-install-r/install-r.Rmd @@ -16,66 +16,90 @@ draft: false This article will explain how to install R, Rstudio, and R packages. -**Please watch the video at the end of the article that gives an overview of using Rstudio and the Rmarkdown format.** +**Please [watch the video](#rmd_movie) that gives an overview of using Rstudio, installing packages, and the Rmarkdown format.** -## Download R +## Installing R Download R from CRAN. Go to the CRAN homepage https://cran.r-project.org/. Select the link to download R for your operating system. -### MacOS +*If you already have R installed, we recommend upgrading to the latest version of R by following the directions below* -Install the newest R version (`4.2.1`). We recommend installing the version for Intel Macs. If you have a Mac with an M1 processor (click the Apple -> About this Mac, see information under `chip`), we still recommend using the Intel version of R as it is much easier to install packages built for the intel version at this time. Download the `.pkg` file, open and follow the prompts to install. +### Windows +Go to [CRAN](https://cran.r-project.org/), and click `Download R for Windows`. Next click the `base` link and select `Download R-4.3.2 for Windows` to download the `.exe` file. Open this file to install R. -### Windows +### MacOS + +Go to [CRAN](https://cran.r-project.org/), and click `Download R for macOS`. Under `Latest Release` there are two options available depending on which CPU is used in your laptop. Mac uses either Intel (x86) or arm64 (i.e. M1 or M2) processors. You can determine which type you have by clicking on the Apple menu and selecting "About this Mac". Next to `Chip` or `Processor`, it will say either M1 or M2, if you have an arm64 CPU, or it will say Intel Core or similar, indicating you have an Intel x86 CPU. + +Download the `R-4.3.2-arm64.pkg` for arm64 or `R-4.3.2-x86_64.pkg` for Intel x86. Open and follow the prompts to install. -Select the `base` link, then click `Download R-4.2.1 for Windows` to download the `.exe` file. Open this file to install R. ### Linux If you are on linux, then follow the documentation for your linux OS. -## Download Rstudio +## Install Rstudio -Go to the [Rstudio website](https://rstudio.com/products/rstudio/download/#download) and download Rstudio Desktop for your OS. +Go to the [Rstudio website](https://posit.co/download/rstudio-desktop/#download) and download Rstudio Desktop for your operating system Once downloaded and installed, open up `Rstudio` to complete the rest of the tutorial. -## Download compiler tools +## Install compiler tools + +Some R package installations may require a compiler, which is usually not available by default on Windows or macOS. + +### Windows + +You need to install `Rtools` from CRAN. Follow this link to download RTools 4.3 using the `Rtools43 installer` https://cran.r-project.org/bin/windows/Rtools/ . ### MacOS To install the necessary compilers, we will follow the recommend steps outlined by CRAN: https://mac.r-project.org/tools/ -You will need to install the xcode command line tools if a package requires compilation. Open Rstudio and click on the "Terminal" pane. Alternatively you can open the Terminal app from `/Applications/Utilities/` (or use the search tool to search for terminal) +#### Xcode +First you will need to install the `Xcode` command line tools. To do so open Rstudio and click on the "Terminal" tab, which is to the right of the "Console" Tab. Alternatively you can open the Terminal app directly from `/Applications/Utilities/` or use the spotlight search tool, search for "terminal", and open the Terminal App. -Type the following into terminal: +Type the following into the terminal and hit `Enter`: ```bash sudo xcode-select --install ``` -Type in your macOS password, press enter and then click “Install”. This download will require ~9Gb. Verify the installation by typing into terminal: +When prompted for `Password:`, type in your macOS user password (you wont see any characters printed as you type), and press enter. Click “Install” in the pop up and agree to the license agreement (if you agree of course). This download will require ~9Gb of space so it will take some time to download and install. Verify the installation by typing into terminal: ```bash gcc --version ``` -Which should print something similar to this: +Which should print something similar to either this: ```bash #' gcc (GCC) 4.8.5 #' Copyright (C) 2015 Free Software Foundation, Inc. #' This is free software; see the source for copying conditions. There is NO #' warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + ``` -Here's a [youtube video explainer](https://www.youtube.com/watch?v=Z01lzHNrSdU&feature=emb_title) - -Next you need to install `gfortran`, which can be obtained from the CRAN instruction site above. We recommend using the intel version of R, so please follow the instructions for Intel Macs and install gfortran using the `gfortran-8.2-Mojave.dmg` installer. +or this: + +```bash +#' Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 +#' Apple clang version 13.0.0 (clang-1300.0.29.30) +#' Target: arm64-apple-darwin21.3.0 +#' Thread model: posix +#' InstalledDir: /Library/Developer/CommandLineTools/usr/bin +``` + +Here's a [youtube video explainer](https://www.youtube.com/watch?v=Z01lzHNrSdU&feature=emb_title) that also shows the process. + +#### gfortran + +Next you need to install `gfortran`. If you've installed the most recent version of R (or at least 4.3.0), then you can install using the [gfortran-12.2-universal.pkg](https://mac.r-project.org/tools/gfortran-12.2-universal.pkg). -Once you've run the `gfortran` installer the last step is to make sure that this program is in your [`PATH`](https://en.wikipedia.org/wiki/PATH_(variable)). This step will make the gfortran program visible to R, and other programs. +Once you've run the `gfortran` installer the last step is to make sure that this program is in your [`PATH`](https://en.wikipedia.org/wiki/PATH_(variable)). This step will make the `gfortran` program visible to R, and other programs. First determine which type of shell you have (typically bash or zsh). Execute the following in a terminal (click either on the terminal pane in Rstudio, or open the terminal app in macOS). @@ -83,30 +107,29 @@ First determine which type of shell you have (typically bash or zsh). Execute th echo $SHELL ``` -If you see `/bin/zsh` then make a plain text file called `.zshrc` in your home directory (e.g. `/Users/Your-macOS-username/`), if it doesn't already exist. If instead you see `/bin/bash` then make a file called `.bashrc` in your home directory, if it doesn't already exist. You can use Rstudio to make a new plain-text file (File->New file->Text) or by opening up the Textedit app, then click Format->Make Plain Text. +If you see `/bin/zsh` then make a plain text file called `.zshrc` in your home directory (e.g. `/Users/Your-macOS-username/.zshrc`), if it doesn't already exist. If instead you see `/bin/bash` then make a file called `.bashrc` in your home directory, if it doesn't already exist. You can use Rstudio to make a new plain-text file (File->New file->Text) or by opening up the Textedit app, then click Format->Make Plain Text. Add the following line of text to the file (and keep any other text if already present). ```bash -export PATH=$PATH:/usr/local/gfortran/bin +export PATH=$PATH:/opt/gfortran/bin ``` -Save the text file to your home directory. You may need to rename the file after saving to ensure that it doesn't end with `.txt.` (e.g. rename `.zshrc.txt` -> `.zshrc`). This file will be a hidden file. Hidden files can be seen in the Finder app by pressing `Command` + `Shift` + `.` (period) to toggle on/off visulizaing hidden files. +Save the text file to your home directory. You may need to rename the file after saving to ensure that it doesn't end with `.txt.` (e.g. rename `.zshrc.txt` -> `.zshrc`). This file will be a hidden file. Hidden files can be seen in the Finder app by pressing `Command` + `Shift` + `.` (period) to toggle on/off visualizing hidden files. Close and reopen Rstudio. -### Windows - -You need to install `Rtools` from CRAN. Go to this link and download the exe installer for your OS: https://cran.r-project.org/bin/windows/Rtools/ ### Linux You should have a compiler available already. ## Installing the tidyverse and Rmarkdown packages -Once you have R and Rstudio set up, open up Rstudio, then we will install packages. Packages are extensions to the base R installation that provide additionally functionality to the language. In this course we will use packages from the [tidyverse](https://www.tidyverse.org/), which is a collection of packages commonly used for data science and interactive data analysis. Installing the `tidyverse` package will install the [entire collection](https://www.tidyverse.org/packages/) of tidyverse packages. +Now that you have R and Rstudio set up we will install packages. -[CRAN](https://cran.r-project.org/) is the official R package repository. CRAN has 18,000+ packages, including the tidyverse packages. Packages from CRAN are installed using the `install.packages()` function. A successful install will only need to be done once for the course. +Packages are extensions to the base R installation that provide additionally functionality to the language. In this course we will use packages from the [tidyverse](https://www.tidyverse.org/), which is a collection of packages commonly used for data science and interactive data analysis. Installing the `tidyverse` package will install an [entire collection](https://www.tidyverse.org/packages/) of tidyverse packages. + +[CRAN](https://cran.r-project.org/) is the official R package repository. CRAN has 18,000+ packages, including the tidyverse packages. Packages from CRAN are installed using the `install.packages()` R function. A successful install of a package will only need to be done once, until you update R to a new version. Open Rstudio to launch R. Then in the console pane, execute the following command to install the [tidyverse](https://www.tidyverse.org/): @@ -155,7 +178,7 @@ install.packages("rmarkdown") and verify installation by running `library(rmarkdown)` -## Introduction to using Rstudio and Rmarkdown +## Introduction to using Rstudio and Rmarkdown {#rmd_movie} Now that you have installed R and Rstudio, please watch this video (~20 minutes) that provides an overview of how to use Rstudio [IDE](https://en.wikipedia.org/wiki/Integrated_development_environment) and an introduction to the [Rmarkdown format](https://rmarkdown.rstudio.com/lesson-1.html). @@ -166,9 +189,8 @@ Now that you have installed R and Rstudio, please watch this video (~20 minutes) ## (Appendix) Installing packages from other sources -**At this point you will only need to install the tidyverse and rmarkdown packages ** -There are 2 additional commonly used repositories for R packages that you should know about: +There are 2 additional commonly used repositories for R packages. These are not needed to complete the prerequisite but are useful resources that you will use as you perform more coding in R. 1) [Bioconductor](https://bioconductor.org/) is a repository that hosts 2,000+ bioinformatics related packages. @@ -191,5 +213,8 @@ For example to install the [LaCroixColorR package](https://github.com/johannesbj ```r install.packages("remotes") remotes::install_github('johannesbjork/LaCroixColoR') + +# or equivalently you could use BiocManager, which uses remotes internally +BiocManager::install(`johannesbjork/LaCroixColoR`) ``` diff --git a/_posts/2022-10-03-install-r/install-r.html b/_posts/2023-11-06-install-r/install-r.html similarity index 85% rename from _posts/2022-10-03-install-r/install-r.html rename to _posts/2023-11-06-install-r/install-r.html index 1073344..74e3b32 100644 --- a/_posts/2022-10-03-install-r/install-r.html +++ b/_posts/2023-11-06-install-r/install-r.html @@ -93,8 +93,8 @@ - - + + @@ -110,12 +110,12 @@ @@ -227,9 +227,21 @@ display: none !important; } + hr.section-separator { + border: none; + border-top: 1px solid rgba(0, 0, 0, 0.1); + margin: 0px; + } + + + d-byline { + border-top: none; + } + d-article { padding-top: 2.5rem; padding-bottom: 30px; + border-top: none; } d-appendix { @@ -326,6 +338,11 @@ font-size: 14px; } + /* tweak for Pandoc numbered line within distill */ + d-article pre.numberSource code > span { + left: -2em; + } + d-article pre { font-size: 14px; } @@ -1085,6 +1102,12 @@ // create d-title $('.d-title').changeElementType('d-title'); + // separator + var separator = '
'; + // prepend separator above appendix + $('.d-byline').before(separator); + $('.d-article').before(separator); + // create d-byline var byline = $(''); $('.d-byline').replaceWith(byline); @@ -1162,8 +1185,9 @@ $('.distill-force-highlighting-css').parent().remove(); // remove empty line numbers inserted by pandoc when using a - // custom syntax highlighting theme - $('code.sourceCode a:empty').remove(); + // custom syntax highlighting theme, except when numbering line + // in code chunk + $('pre:not(.numberLines) code.sourceCode a:empty').remove(); // load distill framework load_distill_framework(); @@ -1189,12 +1213,13 @@ // add orcid ids $('.authors-affiliations').find('.author').each(function(i, el) { var orcid_id = front_matter.authors[i].orcidID; + var author_name = front_matter.authors[i].author if (orcid_id) { var a = $(''); a.attr('href', 'https://orcid.org/' + orcid_id); var img = $(''); img.addClass('orcid-id'); - img.attr('alt', 'ORCID ID'); + img.attr('alt', author_name ? 'ORCID ID for ' + author_name : 'ORCID ID'); img.attr('src','data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo1N0NEMjA4MDI1MjA2ODExOTk0QzkzNTEzRjZEQTg1NyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDozM0NDOEJGNEZGNTcxMUUxODdBOEVCODg2RjdCQ0QwOSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozM0NDOEJGM0ZGNTcxMUUxODdBOEVCODg2RjdCQ0QwOSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkZDN0YxMTc0MDcyMDY4MTE5NUZFRDc5MUM2MUUwNEREIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjU3Q0QyMDgwMjUyMDY4MTE5OTRDOTM1MTNGNkRBODU3Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+84NovQAAAR1JREFUeNpiZEADy85ZJgCpeCB2QJM6AMQLo4yOL0AWZETSqACk1gOxAQN+cAGIA4EGPQBxmJA0nwdpjjQ8xqArmczw5tMHXAaALDgP1QMxAGqzAAPxQACqh4ER6uf5MBlkm0X4EGayMfMw/Pr7Bd2gRBZogMFBrv01hisv5jLsv9nLAPIOMnjy8RDDyYctyAbFM2EJbRQw+aAWw/LzVgx7b+cwCHKqMhjJFCBLOzAR6+lXX84xnHjYyqAo5IUizkRCwIENQQckGSDGY4TVgAPEaraQr2a4/24bSuoExcJCfAEJihXkWDj3ZAKy9EJGaEo8T0QSxkjSwORsCAuDQCD+QILmD1A9kECEZgxDaEZhICIzGcIyEyOl2RkgwAAhkmC+eAm0TAAAAABJRU5ErkJggg=='); a.append(img); $(this).append(a); @@ -1472,7 +1497,7 @@ - + @@ -1493,7 +1518,7 @@ @@ -1504,6 +1529,7 @@

Prerequisite: R installation and Rmarkdown/Rstudio overview

+ @@ -1512,7 +1538,7 @@

Prerequisite: R installation and Rmarkdown/Rstudio overview

@@ -1520,75 +1546,87 @@

Prerequisite: R installation and Rmarkdown/Rstudio overview

This article will explain how to install R, Rstudio, and R packages.

-

Please watch the video at the end of the article that gives an overview of using Rstudio and the Rmarkdown format.

-

Download R

+

Please watch the video that gives an overview of using Rstudio, installing packages, and the Rmarkdown format.

+

Installing R

Download R from CRAN. Go to the CRAN homepage https://cran.r-project.org/. Select the link to download R for your operating system.

-

MacOS

-

Install the newest R version (4.2.1). We recommend installing the version for Intel Macs. If you have a Mac with an M1 processor (click the Apple -> About this Mac, see information under chip), we still recommend using the Intel version of R as it is much easier to install packages built for the intel version at this time. Download the .pkg file, open and follow the prompts to install.

+

If you already have R installed, we recommend upgrading to the latest version of R by following the directions below

Windows

-

Select the base link, then click Download R-4.2.1 for Windows to download the .exe file. Open this file to install R.

+

Go to CRAN, and click Download R for Windows. Next click the base link and select Download R-4.3.2 for Windows to download the .exe file. Open this file to install R.

+

MacOS

+

Go to CRAN, and click Download R for macOS. Under Latest Release there are two options available depending on which CPU is used in your laptop. Mac uses either Intel (x86) or arm64 (i.e. M1 or M2) processors. You can determine which type you have by clicking on the Apple menu and selecting “About this Mac”. Next to Chip or Processor, it will say either M1 or M2, if you have an arm64 CPU, or it will say Intel Core or similar, indicating you have an Intel x86 CPU.

+

Download the R-4.3.2-arm64.pkg for arm64 or R-4.3.2-x86_64.pkg for Intel x86. Open and follow the prompts to install.

Linux

If you are on linux, then follow the documentation for your linux OS.

-

Download Rstudio

-

Go to the Rstudio website and download Rstudio Desktop for your OS.

+

Install Rstudio

+

Go to the Rstudio website and download Rstudio Desktop for your operating system

Once downloaded and installed, open up Rstudio to complete the rest of the tutorial.

-

Download compiler tools

+

Install compiler tools

+

Some R package installations may require a compiler, which is usually not available by default on Windows or macOS.

+

Windows

+

You need to install Rtools from CRAN. Follow this link to download RTools 4.3 using the Rtools43 installer https://cran.r-project.org/bin/windows/Rtools/ .

MacOS

To install the necessary compilers, we will follow the recommend steps outlined by CRAN: https://mac.r-project.org/tools/

-

You will need to install the xcode command line tools if a package requires compilation. Open Rstudio and click on the “Terminal” pane. Alternatively you can open the Terminal app from /Applications/Utilities/ (or use the search tool to search for terminal)

-

Type the following into terminal:

+

Xcode

+

First you will need to install the Xcode command line tools. To do so open Rstudio and click on the “Terminal” tab, which is to the right of the “Console” Tab. Alternatively you can open the Terminal app directly from /Applications/Utilities/ or use the spotlight search tool, search for “terminal”, and open the Terminal App.

+

Type the following into the terminal and hit Enter:

sudo xcode-select --install
-

Type in your macOS password, press enter and then click “Install”. This download will require ~9Gb. Verify the installation by typing into terminal:

+

When prompted for Password:, type in your macOS user password (you wont see any characters printed as you type), and press enter. Click “Install” in the pop up and agree to the license agreement (if you agree of course). This download will require ~9Gb of space so it will take some time to download and install. Verify the installation by typing into terminal:

gcc --version
-

Which should print something similar to this:

+

Which should print something similar to either this:

#' gcc (GCC) 4.8.5
 #' Copyright (C) 2015 Free Software Foundation, Inc.
 #' This is free software; see the source for copying conditions.  There is NO
 #' warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-

Here’s a youtube video explainer

-

Next you need to install gfortran, which can be obtained from the CRAN instruction site above. We recommend using the intel version of R, so please follow the instructions for Intel Macs and install gfortran using the gfortran-8.2-Mojave.dmg installer.

-

Once you’ve run the gfortran installer the last step is to make sure that this program is in your PATH. This step will make the gfortran program visible to R, and other programs.

+

or this:

+
#' Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
+#' Apple clang version 13.0.0 (clang-1300.0.29.30)
+#' Target: arm64-apple-darwin21.3.0
+#' Thread model: posix
+#' InstalledDir: /Library/Developer/CommandLineTools/usr/bin
+

Here’s a youtube video explainer that also shows the process.

+

gfortran

+

Next you need to install gfortran. If you’ve installed the most recent version of R (or at least 4.3.0), then you can install using the gfortran-12.2-universal.pkg.

+

Once you’ve run the gfortran installer the last step is to make sure that this program is in your PATH. This step will make the gfortran program visible to R, and other programs.

First determine which type of shell you have (typically bash or zsh). Execute the following in a terminal (click either on the terminal pane in Rstudio, or open the terminal app in macOS).

-
echo $SHELL
-

If you see /bin/zsh then make a plain text file called .zshrc in your home directory (e.g. /Users/Your-macOS-username/), if it doesn’t already exist. If instead you see /bin/bash then make a file called .bashrc in your home directory, if it doesn’t already exist. You can use Rstudio to make a new plain-text file (File->New file->Text) or by opening up the Textedit app, then click Format->Make Plain Text.

+
echo $SHELL
+

If you see /bin/zsh then make a plain text file called .zshrc in your home directory (e.g. /Users/Your-macOS-username/.zshrc), if it doesn’t already exist. If instead you see /bin/bash then make a file called .bashrc in your home directory, if it doesn’t already exist. You can use Rstudio to make a new plain-text file (File->New file->Text) or by opening up the Textedit app, then click Format->Make Plain Text.

Add the following line of text to the file (and keep any other text if already present).

-
export PATH=$PATH:/usr/local/gfortran/bin
-

Save the text file to your home directory. You may need to rename the file after saving to ensure that it doesn’t end with .txt. (e.g. rename .zshrc.txt -> .zshrc). This file will be a hidden file. Hidden files can be seen in the Finder app by pressing Command + Shift + . (period) to toggle on/off visulizaing hidden files.

+
export PATH=$PATH:/opt/gfortran/bin
+

Save the text file to your home directory. You may need to rename the file after saving to ensure that it doesn’t end with .txt. (e.g. rename .zshrc.txt -> .zshrc). This file will be a hidden file. Hidden files can be seen in the Finder app by pressing Command + Shift + . (period) to toggle on/off visualizing hidden files.

Close and reopen Rstudio.

-

Windows

-

You need to install Rtools from CRAN. Go to this link and download the exe installer for your OS: https://cran.r-project.org/bin/windows/Rtools/

Linux

You should have a compiler available already.

Installing the tidyverse and Rmarkdown packages

-

Once you have R and Rstudio set up, open up Rstudio, then we will install packages. Packages are extensions to the base R installation that provide additionally functionality to the language. In this course we will use packages from the tidyverse, which is a collection of packages commonly used for data science and interactive data analysis. Installing the tidyverse package will install the entire collection of tidyverse packages.

-

CRAN is the official R package repository. CRAN has 18,000+ packages, including the tidyverse packages. Packages from CRAN are installed using the install.packages() function. A successful install will only need to be done once for the course.

+

Now that you have R and Rstudio set up we will install packages.

+

Packages are extensions to the base R installation that provide additionally functionality to the language. In this course we will use packages from the tidyverse, which is a collection of packages commonly used for data science and interactive data analysis. Installing the tidyverse package will install an entire collection of tidyverse packages.

+

CRAN is the official R package repository. CRAN has 18,000+ packages, including the tidyverse packages. Packages from CRAN are installed using the install.packages() R function. A successful install of a package will only need to be done once, until you update R to a new version.

Open Rstudio to launch R. Then in the console pane, execute the following command to install the tidyverse:

-
install.packages("tidyverse")
+
install.packages("tidyverse")

This command will take a few minutes to run while all of the packages are installed. Package installation will be completed once the > prompt reappears. Once complete, test package installation by loading the package(s)

-
library(tidyverse)
+
library(tidyverse)

If successful you will see something like this:

@@ -1599,34 +1637,36 @@

Installing the tidyvers

If loading tidyverse completes without errors then the packages have been installed. You’ll also now see additional packages (ggplot2, dplyr, tidyr) listed under the “Packages” pane.

If there is an error installing tidyverse, you’ll likely see the following at the end of the command:

-
#' Warning in install.packages :
-#'  installation of package ‘tidyverse’ had non-zero exit status
+
#' Warning in install.packages :
+#'  installation of package ‘tidyverse’ had non-zero exit status

If this happens, contact the course instructors to help troubleshoot the installation issue.

Another package that we will use in the course is rmarkdown, to install run:

-
install.packages("rmarkdown")
+
install.packages("rmarkdown")

and verify installation by running library(rmarkdown)

-

Introduction to using Rstudio and Rmarkdown

+

Introduction to using Rstudio and Rmarkdown

Now that you have installed R and Rstudio, please watch this video (~20 minutes) that provides an overview of how to use Rstudio IDE and an introduction to the Rmarkdown format.

intro-to-rstudio.mp4

intro-to-rstudio.mov

(Appendix) Installing packages from other sources

-

At this point you will only need to install the tidyverse and rmarkdown packages

-

There are 2 additional commonly used repositories for R packages that you should know about:

+

There are 2 additional commonly used repositories for R packages. These are not needed to complete the prerequisite but are useful resources that you will use as you perform more coding in R.

  1. Bioconductor is a repository that hosts 2,000+ bioinformatics related packages.

To install bioconductor packages you should use the CRAN package BiocManager. BiocManager has a function called install() to install bioconductor packages. For example to install ComplexHeatmap

-
install.packages("BiocManager")
-
library(BiocManager)
-install("ComplexHeatmap")
-# or equivalently you could run BiocManager::install("ComplexHeatmap")
+
install.packages("BiocManager")
+
library(BiocManager)
+install("ComplexHeatmap")
+# or equivalently you could run BiocManager::install("ComplexHeatmap")
  1. Github hosts open-source code from millions of software projects. R packages hosted on github can be installed using the remotes package. Packages on github are generally the development version of a package, or a package that has not been contributed to either CRAN or Bioconductor. To install you’ll need to find the organization name and the repository name on github to install.

For example to install the LaCroixColorR package:

-
install.packages("remotes")
-remotes::install_github('johannesbjork/LaCroixColoR')
-
+
install.packages("remotes")
+remotes::install_github('johannesbjork/LaCroixColoR')
+
+# or equivalently you could use BiocManager, which uses remotes internally
+BiocManager::install(`johannesbjork/LaCroixColoR`)
+
diff --git a/_posts/2022-10-03-install-r/install-r_files/anchor-4.2.2/anchor.min.js b/_posts/2023-11-06-install-r/install-r_files/anchor-4.2.2/anchor.min.js similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/anchor-4.2.2/anchor.min.js rename to _posts/2023-11-06-install-r/install-r_files/anchor-4.2.2/anchor.min.js diff --git a/_posts/2022-10-03-install-r/install-r_files/bowser-1.9.3/bowser.min.js b/_posts/2023-11-06-install-r/install-r_files/bowser-1.9.3/bowser.min.js similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/bowser-1.9.3/bowser.min.js rename to _posts/2023-11-06-install-r/install-r_files/bowser-1.9.3/bowser.min.js diff --git a/_posts/2022-10-03-install-r/install-r_files/distill-2.2.21/template.v2.js b/_posts/2023-11-06-install-r/install-r_files/distill-2.2.21/template.v2.js similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/distill-2.2.21/template.v2.js rename to _posts/2023-11-06-install-r/install-r_files/distill-2.2.21/template.v2.js diff --git a/_posts/2022-10-03-install-r/install-r_files/header-attrs-2.14/header-attrs.js b/_posts/2023-11-06-install-r/install-r_files/header-attrs-2.14/header-attrs.js similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/header-attrs-2.14/header-attrs.js rename to _posts/2023-11-06-install-r/install-r_files/header-attrs-2.14/header-attrs.js diff --git a/_posts/2023-11-06-install-r/install-r_files/header-attrs-2.25/header-attrs.js b/_posts/2023-11-06-install-r/install-r_files/header-attrs-2.25/header-attrs.js new file mode 100644 index 0000000..dd57d92 --- /dev/null +++ b/_posts/2023-11-06-install-r/install-r_files/header-attrs-2.25/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/_posts/2022-10-03-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.js b/_posts/2023-11-06-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.js similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.js rename to _posts/2023-11-06-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.js diff --git a/_posts/2022-10-03-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.min.js b/_posts/2023-11-06-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.min.js similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.min.js rename to _posts/2023-11-06-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.min.js diff --git a/_posts/2022-10-03-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.min.map b/_posts/2023-11-06-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.min.map similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.min.map rename to _posts/2023-11-06-install-r/install-r_files/jquery-3.6.0/jquery-3.6.0.min.map diff --git a/_posts/2022-10-03-install-r/install-r_files/popper-2.6.0/popper.min.js b/_posts/2023-11-06-install-r/install-r_files/popper-2.6.0/popper.min.js similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/popper-2.6.0/popper.min.js rename to _posts/2023-11-06-install-r/install-r_files/popper-2.6.0/popper.min.js diff --git a/_posts/2022-10-03-install-r/install-r_files/tippy-6.2.7/tippy-bundle.umd.min.js b/_posts/2023-11-06-install-r/install-r_files/tippy-6.2.7/tippy-bundle.umd.min.js similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/tippy-6.2.7/tippy-bundle.umd.min.js rename to _posts/2023-11-06-install-r/install-r_files/tippy-6.2.7/tippy-bundle.umd.min.js diff --git a/_posts/2022-10-03-install-r/install-r_files/tippy-6.2.7/tippy-light-border.css b/_posts/2023-11-06-install-r/install-r_files/tippy-6.2.7/tippy-light-border.css similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/tippy-6.2.7/tippy-light-border.css rename to _posts/2023-11-06-install-r/install-r_files/tippy-6.2.7/tippy-light-border.css diff --git a/_posts/2022-10-03-install-r/install-r_files/tippy-6.2.7/tippy.css b/_posts/2023-11-06-install-r/install-r_files/tippy-6.2.7/tippy.css similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/tippy-6.2.7/tippy.css rename to _posts/2023-11-06-install-r/install-r_files/tippy-6.2.7/tippy.css diff --git a/_posts/2022-10-03-install-r/install-r_files/tippy-6.2.7/tippy.umd.min.js b/_posts/2023-11-06-install-r/install-r_files/tippy-6.2.7/tippy.umd.min.js similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/tippy-6.2.7/tippy.umd.min.js rename to _posts/2023-11-06-install-r/install-r_files/tippy-6.2.7/tippy.umd.min.js diff --git a/_posts/2022-10-03-install-r/install-r_files/webcomponents-2.0.0/webcomponents.js b/_posts/2023-11-06-install-r/install-r_files/webcomponents-2.0.0/webcomponents.js similarity index 100% rename from _posts/2022-10-03-install-r/install-r_files/webcomponents-2.0.0/webcomponents.js rename to _posts/2023-11-06-install-r/install-r_files/webcomponents-2.0.0/webcomponents.js diff --git a/classes.Rmd b/classes.Rmd index 210a7f7..4df620f 100644 --- a/classes.Rmd +++ b/classes.Rmd @@ -3,17 +3,5 @@ title: "Practical Biological Data Analysis" site: distill::distill_website listing: posts: - - 2022-12-05-a-collection-of-r-resources - - 2022-12-05-class-11-programming-in-r-pt2 - - 2022-12-05-class-10-programming-in-r-part-1 - - 2022-11-16-class-9-heatmap - - 2022-11-15-class-8-clustering - - 2022-11-10-class-7-matricies - - 2022-11-23-class-6-intro-to-ggplot2-part3 - - 2022-11-23-class-5-intro-to-ggplot2-part2 - - 2022-11-17-class-4-intro-to-ggplot2 - - 2022-11-15-class-3-reshaping-data-into-a-tidy-format - - 2022-10-04-class-2 - - 2022-10-03-intro-to-r-language - - 2022-10-03-install-r + - 2023-11-06-install-r --- diff --git a/ex/prerequisite.Rmd b/ex/prerequisite.Rmd index 2b5f337..a7d27f4 100644 --- a/ex/prerequisite.Rmd +++ b/ex/prerequisite.Rmd @@ -8,22 +8,24 @@ output: html_document knitr::opts_chunk$set(echo = TRUE) ``` -**This assignment is due prior to the start of class, Nov 29th before midnight** +**This assignment is due Nov 29th before midnight** -If you run into issues, please follow the instructions provided in the [R package installation and Rstudio overview](https://rnabioco.github.io/bmsc-7810-pbda/posts/2022-10-03-install-r/), or contact the instructors via email (rbi.fellows@cuanschutz.edu). +Please read the instructions and watch the video (~20 min) provided in the [R package installation and Rstudio overview](https://rnabioco.github.io/bmsc-7810-pbda/posts/2023-11-06-install-r). -This assignment is a simple test to ensure that your R and Rstudio installation is set up. +This assignment is designed to check that your R and Rstudio installation is set up correctly. If this assignment is taking more than 1 hour of your time please contact the instructors for assistance (rbi.fellows@cuanschutz.edu). + +Please perform the following: 1) Change the title of this Rmarkdown to include your name e.g. (`Kent Riemondy Prerequisite assignment`) -2) Add a R code chunk to the document that loads the `tidyverse` package, using the `library` function. +2) Add a R code chunk to the document and load the `tidyverse` package, using the `library()` function. -3) Knit this RMarkdown document to html output. +3) Knit this R Markdown document to generate HTML output (click the `Knit` needle and yarn icon). -4) Submit the html document to canvas. +4) Submit the html document to Canvas. -Keep the following code chunk in your rmarkdown, as it will demonstrate which packages you've installed. +Keep the following code chunk in your R Markdown, as it will demonstrate which packages you've installed. ```{r} sessionInfo() diff --git a/index.Rmd b/index.Rmd index a4ffcdf..e3f9bac 100644 --- a/index.Rmd +++ b/index.Rmd @@ -15,7 +15,7 @@ knitr::opts_chunk$set(echo = TRUE) ## Overview -In this short course you will learn to analyze and visualize complex data sets using the R statistical programming language, the RStudio IDE and new tools available in the "tidyverse”. We will focus on key analysis skills and foundational programming concepts necessary for the efficient and reproducible analysis of biological data sets. +In this short course you will learn to analyze and visualize complex data sets using the R statistical programming language and the RStudio IDE. We will focus on key analysis skills and foundational programming concepts necessary for the efficient and reproducible analysis of biological data sets. ## Organization and Contacts @@ -27,7 +27,7 @@ Ryan Sheridan (Instructor): ryan.sheridan@cuanschutz.edu Kristen Wells-Wrasman (Instructor): kristen.wells-wrasman@cuanschutz.edu -The course (2 credit hours) consists of 13 2 hour classes held Mon through Fri from Nov 30 through Dec 16 from 8:00 -10:00 am. The course will be held at the Strauss Health Science Library (V23) in the HS Library Teaching Lab 2. All classes will be recorded and made available through Canvas. +The course (2 credit hours) consists of 13 two hour classes held Mon through Fri from Nov 29 through Dec 15 from 8:00 -10:00 am. The course will be held in Research 1 North (P18) in the P18-CTL-1309 Computer lab. All classes will be recorded and made available through Canvas. Virtual office hours will also be provided outside of course hours. @@ -43,7 +43,7 @@ A personal computer with a common operating system ( macOS, Linux, or Windows), ## Assignments -Student's grades will be determined by completion of the prerequisite assignment (10%), class participation (10%), and 4 homework assignments (80%), to be completed by the end of the course. +Student's grades will be determined by completion of the prerequisite assignment (5%), class participation (10%), and 4 homework assignments (80%), to be completed by the end of the course. # Course assistance We will provide a Slack workspace for discussion during and after classes, to collaborate, and to get help. In addition the course instructors will hold virtual office hours to provide assistance outside of the course. Please email the course instructors via (`rbi.fellows@cuanschutz.edu`) to schedule a time. diff --git a/schedule.Rmd b/schedule.Rmd index ba2c00b..313f605 100644 --- a/schedule.Rmd +++ b/schedule.Rmd @@ -4,50 +4,51 @@ title: "Schedule" # Class Schedule -- Class 1: Wednesday, Nov. 30th + +- Class 1: Wednesday, Nov. 29 + Introduction to the R statistical programming language -- Class 2: Thursday, Dec. 1st +- Class 2: Thursday, Nov. 30 + + R fundamentals + +- Class 3: Friday, Dec. 1 + Data wrangling with the tidyverse -- Class 3: Friday, Dec. 2nd +- Class 4: Monday, Dec. 4 + Reshaping data into a tidy format -- Class 4: Monday, Dec. 5th +- Class 5: Tuesday, Dec. 5 + Introduction to ggplot2 (pt.1) -- Class 5: Tuesday, Dec. 6th +- Class 6: Wednesday, Dec. 6 + Introduction to ggplot2 (pt.2) -- Class 6: Wednesday, Dec. 7th - + Introduction to ggplot2 (pt.3) +- Class 7: Thursday, Dec. 7 + + Data analysis vignette -- Class 7: Thursday, Dec. 8th +- Class 8: Friday, Dec. 8 + Introduction to matrix operations -- Class 8: Friday, Dec. 9th +- Class 9: Monday, Dec. 11 + Introduction to clustering techniques -- Class 9: Monday, Dec. 12th - + Introduction to Heatmaps +- Class 10: Tuesday, Dec. 12 + + Introduction to visualizing data with heatmaps -- Class 10: Tuesday, Dec. 13th - + Introduction to programming in R (pt. 1) +- Class 11: Wednesday, Dec. 13 + + Programming fundamentals in R (pt. 1) -- Wednesday, Dec. 14th - + **No Class** +- Class 12: Thursday, Dec. 14 + + Programming fundamentals in R (pt. 2) -- Class 11: Thursday, Dec. 15th - + Introduction to programming in R (pt. 2) - -- Class 12: Friday, Dec. 16th +- Class 13: Friday, Dec. 15 + Course wrap up # Problem Sets -- Problem set 1: Due Tues Dec 6th (9a) -- Problem set 2: Due Friday Dec 9th (5p) -- Problem set 3: Due Thursday Dec. 15th (5p) -- Problem set 4: Due Monday Dec. 19th (5p) +- Problem set 1: Due Friday Dec 1 (5p) +- Problem set 2: Due Tuesday Dec 5 (5p) +- Problem set 3: Due Friday Dec. 8 (5p) +- Problem set 4: Due Wednesday Dec. 13 (5p)