Difference between revisions of "Workshops/Saskatoon 2015-Introduction to R"
m (→Module 1) |
m (→Resources) |
||
(13 intermediate revisions by the same user not shown) | |||
Line 71: | Line 71: | ||
==Setup== | ==Setup== | ||
− | |||
− | |||
− | + | '''R''' and R Studio must be installed on your computer. | |
+ | |||
+ | |||
+ | You must have a working internet connection in this room. | ||
+ | |||
+ | |||
+ | | ||
+ | |||
− | + | ---- | |
− | |||
− | |||
− | |||
− | + | Here is a PDF of the slides I will use today. It is unlikely you will actually need them. | |
− | |||
− | |||
− | |||
− | + | ;[[Media:Intro_to_R-slides.pdf|Introduction to R: slides (pdf)]] | |
− | |||
---- | ---- | ||
+ | |||
+ | |||
+ | This is your first task. Everything else is in the script file: | ||
{{task| | {{task| | ||
− | # Download the file | + | # Download the script file '''[[Media:Intro_to_R.R|Intro_to_R.R]]''' to your working directory; |
− | # | + | # Load the file in R Studio; |
− | # | + | # Proceed to the first {{C|CHECKPOINT}} in the script. |
− | |||
}} | }} | ||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | |||
− | == | + | ==Resources== |
+ | Here are links to various files you will need today. The script file will instruct you what is needed at what time. | ||
Line 114: | Line 120: | ||
*[[Media:ScriptTemplate.R|ScriptTemplate.R]] | *[[Media:ScriptTemplate.R|ScriptTemplate.R]] | ||
*[[Media:Utilities.R|Utilities.R]] | *[[Media:Utilities.R|Utilities.R]] | ||
+ | *[[Media:Intro_to_R_SampleSolutionsForTasks.R|Intro_to_R_SampleSolutionsForTasks.R]] | ||
+ | *[[Media:PlottingReference.R|PlottingReference.R]] | ||
+ | |||
+ | |||
+ | ;Jaitin ''et al''. (2014) Resources | ||
+ | {{#pmid: 24531970}} Hm. Did PubMed block us? | ||
+ | *[[Media:Jaitin_2014-SingleCellRNAseq.pdf|Jaitin_2014-SingleCellRNAseq.pdf]] <small>You might download this paper at any time and browse through it if you have a few spare minutes in between.</small> | ||
+ | *[[Media:Jaitin-SupplementaryMaterial.pdf|Jaitin-SupplementaryMaterial.pdf]] <small>Same with the Supplementary Material.</small> | ||
+ | *[[Media:Fig_3-CharacteristicGenes.txt|Fig_3-CharacteristicGenes.txt]] | ||
+ | *[[Media:Table_S3.xls|Table_S3.xls]] | ||
+ | *<small>As backup, in case you don't have Excel: [[Media:Table_S3.csv|Table_S3.csv]]</small> | ||
+ | |||
+ | |||
+ | |||
+ | ;Other resources | ||
+ | *[[Media:Weissgerber_(2015)_BeyondBarcharts.pdf|Weissgerber_(2015)_BeyondBarcharts.pdf]] | ||
+ | *[[Media:R_refcard.pdf|A concise reference card of '''R''' functions (pdf)]] | ||
+ | |||
+ | |||
+ | | ||
+ | ==Progress Notes== | ||
+ | |||
+ | Selected objectives we covered during the workshop: | ||
+ | |||
+ | * setup a working directory | ||
+ | * load file | ||
+ | * use a script template | ||
+ | * installing and loading packages | ||
+ | * searching for functions | ||
+ | * listing directory contents | ||
+ | |||
+ | ---- | ||
+ | |||
+ | * used the source() function | ||
+ | * created/edited .Rprofile to modify startup behaviour | ||
+ | * discussed anatomy of a function: | ||
+ | ** assignment | ||
+ | ** parameters/arguments | ||
+ | ** function body | ||
+ | * variables | ||
+ | * print() vs. cat() | ||
+ | * sprintf() ... when you have time read [https://stat.ethz.ch/R-manual/R-devel/library/base/html/sprintf.html '''here''' (sprintf help)] about formatting options | ||
+ | * round(), floor(), ceiling() | ||
+ | |||
+ | ---- | ||
+ | |||
+ | * Preparing input data for R (csv is your friend!) | ||
+ | * Actually reading files into dataframes | ||
+ | * setting rownames() and colnames() | ||
+ | * using strsplit(), substr() for string manipulation | ||
+ | * discussed vectors and lists and dataframes | ||
+ | * stringsAsFactors = FALSE | ||
+ | * first encounter of subsetting | ||
| | ||
+ | |||
+ | ==Useful links== | ||
+ | |||
+ | * The '''R''' help mailing list: https://stat.ethz.ch/mailman/listinfo/r-help | ||
+ | * '''Rseek''': the specialized search engine for '''R''' topics: http://rseek.org/ | ||
+ | * '''R''' questions on stackoverflow: http://stackoverflow.com/questions/tagged/r | ||
+ | * The Comprehensive '''R''' Archive Network '''CRAN''': http://cran.r-project.org/ | ||
+ | * The '''CRAN''' task-view collection: http://cran.r-project.org/web/views/ | ||
+ | * '''Bioconductor''' task views: http://www.bioconductor.org/packages/release/BiocViews.html | ||
+ | |||
+ | |||
==Notes== | ==Notes== | ||
<references /> | <references /> | ||
+ | |||
+ | |||
+ | <div style="padding: 5px; border: solid 1px #000000; background-color: #EEEEF6;font-size: 85%"> | ||
+ | There may be a difference between '''R''' and R Studio regarding the location of installed packages. | ||
+ | |||
+ | We have noticed at previous workshops that RStudio couldn't find libraries that were not installed through the RStudio package manager. This appeared to have been version dependent, and may not affect current releases. You can check for this (in case you have problems running the {{C|library()}} command) by issuing the command ... | ||
+ | |||
+ | <source lang="R"> | ||
+ | .libPaths() | ||
+ | </source> | ||
+ | |||
+ | ...in '''R''' as well as in R Studio. The path should be the same in both. | ||
+ | |||
+ | In case you need to "tell" RStudio the location, you can define the path in a startup file. Create or edit a file called <code>.Renviron</code> in your home directory. Inside there define: | ||
+ | |||
+ | <source lang="R"> | ||
+ | R_LIBS=<Library Path of R installed packages> | ||
+ | </source> | ||
+ | |||
+ | Alternatively, you could use the R Studio package manger to install libraries. | ||
+ | </div> | ||
</div> | </div> |
Latest revision as of 19:05, 23 August 2015
Introduction to R
Schedule
Please note: this schedule is a rough guideline only, we will be very flexible to adapt to class needs as we proceed.
Time | Wednesday's Activities |
09:00 – 10:30 | Welcome, Introduction Lecture and practicals: setup and environment |
10:30 – 11:00 | Coffee break |
11:00 – 12:30 | Lecture and practicals: R commands |
12:30 – 13:30 | Lunch break |
13:30 – 15:00 | Lecture and practicals: programming |
15:00 – 15:30 | Coffee break |
13:30 – 15:00 | Lecture and practicals: data |
Setup
R and R Studio must be installed on your computer.
You must have a working internet connection in this room.
Here is a PDF of the slides I will use today. It is unlikely you will actually need them.
This is your first task. Everything else is in the script file:
Task:
- Download the script file Intro_to_R.R to your working directory;
- Load the file in R Studio;
- Proceed to the first
CHECKPOINT
in the script.
Resources
Here are links to various files you will need today. The script file will instruct you what is needed at what time.
- Script files for this section
- Jaitin et al. (2014) Resources
Jaitin et al. (2014) Massively parallel single-cell RNA-seq for marker-free decomposition of tissues into cell types. Science 343:776-9. (pmid: 24531970) |
[ PubMed ] [ DOI ] In multicellular organisms, biological function emerges when heterogeneous cell types form complex organs. Nevertheless, dissection of tissues into mixtures of cellular subpopulations is currently challenging. We introduce an automated massively parallel single-cell RNA sequencing (RNA-seq) approach for analyzing in vivo transcriptional states in thousands of single cells. Combined with unsupervised classification algorithms, this facilitates ab initio cell-type characterization of splenic tissues. Modeling single-cell transcriptional states in dendritic cells and additional hematopoietic cell types uncovers rich cell-type heterogeneity and gene-modules activity in steady state and after pathogen activation. Cellular diversity is thereby approached through inference of variable and dynamic pathway activity rather than a fixed preprogrammed cell-type hierarchy. These data demonstrate single-cell RNA-seq as an effective tool for comprehensive cellular decomposition of complex tissues. |
- Jaitin_2014-SingleCellRNAseq.pdf You might download this paper at any time and browse through it if you have a few spare minutes in between.
- Jaitin-SupplementaryMaterial.pdf Same with the Supplementary Material.
- Fig_3-CharacteristicGenes.txt
- Table_S3.xls
- As backup, in case you don't have Excel: Table_S3.csv
- Other resources
Progress Notes
Selected objectives we covered during the workshop:
- setup a working directory
- load file
- use a script template
- installing and loading packages
- searching for functions
- listing directory contents
- used the source() function
- created/edited .Rprofile to modify startup behaviour
- discussed anatomy of a function:
- assignment
- parameters/arguments
- function body
- variables
- print() vs. cat()
- sprintf() ... when you have time read here (sprintf help) about formatting options
- round(), floor(), ceiling()
- Preparing input data for R (csv is your friend!)
- Actually reading files into dataframes
- setting rownames() and colnames()
- using strsplit(), substr() for string manipulation
- discussed vectors and lists and dataframes
- stringsAsFactors = FALSE
- first encounter of subsetting
Useful links
- The R help mailing list: https://stat.ethz.ch/mailman/listinfo/r-help
- Rseek: the specialized search engine for R topics: http://rseek.org/
- R questions on stackoverflow: http://stackoverflow.com/questions/tagged/r
- The Comprehensive R Archive Network CRAN: http://cran.r-project.org/
- The CRAN task-view collection: http://cran.r-project.org/web/views/
- Bioconductor task views: http://www.bioconductor.org/packages/release/BiocViews.html
Notes
There may be a difference between R and R Studio regarding the location of installed packages.
We have noticed at previous workshops that RStudio couldn't find libraries that were not installed through the RStudio package manager. This appeared to have been version dependent, and may not affect current releases. You can check for this (in case you have problems running the library()
command) by issuing the command ...
.libPaths()
...in R as well as in R Studio. The path should be the same in both.
In case you need to "tell" RStudio the location, you can define the path in a startup file. Create or edit a file called .Renviron
in your home directory. Inside there define:
R_LIBS=<Library Path of R installed packages>
Alternatively, you could use the R Studio package manger to install libraries.