From 7c47af1b3dff4cf473c5e2aaa318b04bdf18bf0e Mon Sep 17 00:00:00 2001 From: hyginn Date: Fri, 18 Aug 2017 22:04:01 +0200 Subject: [PATCH] Install files and folders --- .Rprofile | 14 ++++++++ .gitignore | 8 +++-- .init.R | 15 +++++++++ .tmp.R | 22 ++++++++++++ .utilities.R | 44 ++++++++++++++++++++++++ ABC-units.R | 84 ++++++++++++++++++++++++++++++++++++++++++++++ ABC-units.Rproj | 16 +++++++++ functionTemplate.R | 33 ++++++++++++++++++ scriptTemplate.R | 68 +++++++++++++++++++++++++++++++++++++ taskSolutions.R | 12 +++++++ 10 files changed, 314 insertions(+), 2 deletions(-) create mode 100644 .Rprofile create mode 100644 .init.R create mode 100644 .tmp.R create mode 100644 .utilities.R create mode 100644 ABC-units.R create mode 100644 ABC-units.Rproj create mode 100644 functionTemplate.R create mode 100644 scriptTemplate.R create mode 100644 taskSolutions.R diff --git a/.Rprofile b/.Rprofile new file mode 100644 index 0000000..957408e --- /dev/null +++ b/.Rprofile @@ -0,0 +1,14 @@ +init <- function() { + source(".init.R") +} + +cat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n") +cat(" =================") +cat("\n\n") +cat(" WELCOME !\n") +cat("\n") +cat(" Type 'init()' to begin\n\n") +cat("\n") +cat(" =================") +cat("\n\n") + diff --git a/.gitignore b/.gitignore index fcff087..2792ba8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ +# Miscellaneous +.Ds_store + # History files .Rhistory .Rapp.history # Session Data files -.RData +# .RData # Example code in package build process *-Ex.R @@ -15,7 +18,7 @@ /*.Rcheck/ # RStudio files -.Rproj.user/ +# .Rproj.user/ # produced vignettes vignettes/*.html @@ -31,3 +34,4 @@ vignettes/*.pdf # Temporary files created by R markdown *.utf8.md *.knit.md +.Rproj.user diff --git a/.init.R b/.init.R new file mode 100644 index 0000000..f446246 --- /dev/null +++ b/.init.R @@ -0,0 +1,15 @@ +# .init.R +# Functions to initialize this collection of learning units +# Boris Steipe +# ==================================================================== + +# Create a local copy of myScript.R if required, and not been done yet. +if (! file.exists("myScript.R") && file.exists(".tmp.R")) { + file.copy(".tmp.R", "myScript.R") +} + +source(".utilities.R") + +file.edit("ABC-units.R") + +# [End] diff --git a/.tmp.R b/.tmp.R new file mode 100644 index 0000000..59384c0 --- /dev/null +++ b/.tmp.R @@ -0,0 +1,22 @@ +# myScript.R +# +# Write your notes and code experiments into this document. Save it +# from time to time - however I recommend that you do not _commit_ +# your saved version. +# +# As long as you do not _commit_ this script to version control, +# you can _pull_ updated versions of the entire project from GitHub +# by using the RStudio version control interface. However, once +# you _commit_ any file in your local version, RStudio will require +# you to resolve conflicts before you can _pull_ updates. +# +# ==================================================================== + + + + + + + +# [END] + diff --git a/.utilities.R b/.utilities.R new file mode 100644 index 0000000..d40e4d6 --- /dev/null +++ b/.utilities.R @@ -0,0 +1,44 @@ +# .utilities.R +# +# Miscellaneous R code to suppport the project +# +# Version: 1.0 +# Date: 2016 12 +# Author: Boris Steipe +# +# V 1.0 First code +# +# ToDo: +# Notes: +# +# ============================================================================== + +objectInfo <- function(x) { + # Function to combine various information items about R objects + # + # Input: an R object + # Value: none - prints information as side-effect + + cat("object contents:") + print(x, digits = 22) # print value at maximal precision + + cat("\nstructure of object:\n") + str(x) + + if (! is.list(x)) { # Don't use cat() if x is a list. cat() can't handle lists. + cat("\nmode: ", mode(x), "\n") + cat("typeof: ", typeof(x), "\n") + cat("class: ", class(x), "\n") + } + + # if the object has attributes, print them too + if (! is.null(attributes(x))) { + cat("\nattributes:\n") + attributes(x) + } + # Done +} + + + +# [END] diff --git a/ABC-units.R b/ABC-units.R new file mode 100644 index 0000000..73fceb7 --- /dev/null +++ b/ABC-units.R @@ -0,0 +1,84 @@ +# ABC-units.R +# +# Purpose: A Bioinformatics Course: R code for learning units +# +# Version: 0. +# +# Date: 2017 08 18 +# Author: Boris Steipe (boris.steipe@utoronto.ca) +# +# V 0.1 First code +# +# TODO: +# +# +# == HOW TO WORK WITH THIS FILE ================================================ +# +# Go through this script line by line to read and understand the +# code. Execute code by typing . When nothing is +# selected, that will execute the current line and move the cursor to +# the next line. You can also select more than one line, e.g. to +# execute a block of code, or less than one line, e.g. to execute +# only the core of a nested expression. +# +# Edit code, as required, experiment with options, or just play. +# Especially play. +# +# DO NOT simply source() this whole file! +# +# If there are portions you don't understand, use R's help system, +# Google for an answer, or ask me. Don't continue if you don't +# understand what's going on. That's not how it works ... +# +# Once you have typed and executed the function init(), you will find a file +# called myScript.R in the project directory. +# +# Open it, you can place all of your code-experiments and notes into that +# file. This will be your "Lab Journal" for this session. +# +# ============================================================================== + +" Introduction: + ... +" + + +# ============================================================================== +# PART ONE: REVIEW +# ============================================================================== + + + + +# == SECTION =================================================================== + + +# == Subsection + +# Continue ... + + + + + + + + +# ============================================================================== +# APPENDIX: OUTLOOK +# ============================================================================== +"There are many more functions for ... that this tutorial did not cover. You should know about the following. Look up the function and write a short bit of example code that uses it:" + +?subset +?sweep +?with # ... and within() + +"Then you should know about the following packages. Open the vignette and browse through it. You should know be able to come up with least one use-case where the package functions would be useful: + + https://cran.r-project.org/web/packages/magrittr/ +" + + + + +# [END] diff --git a/ABC-units.Rproj b/ABC-units.Rproj new file mode 100644 index 0000000..0fbb9ec --- /dev/null +++ b/ABC-units.Rproj @@ -0,0 +1,16 @@ +Version: 1.0 + +RestoreWorkspace: No +SaveWorkspace: No +AlwaysSaveHistory: No + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: knitr +LaTeX: XeLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes diff --git a/functionTemplate.R b/functionTemplate.R new file mode 100644 index 0000000..73f2d9e --- /dev/null +++ b/functionTemplate.R @@ -0,0 +1,33 @@ +# functionTemplate.R +# +# Purpose: (General) +# +# ToDo: +# Notes: +# +# ============================================================================== + +myFunction <- function(a, b=1) { + # Purpose: + # Describe ... + # Version: + # Date: + # Author: + # + # Parameters: + # a: ... + # b: ... + # Value: + # result: ... + + # code ... + + return(result) +} + + +# ==== TESTS ================================================================= +# Enter your function tests here... + + +# [END] diff --git a/scriptTemplate.R b/scriptTemplate.R new file mode 100644 index 0000000..a394a34 --- /dev/null +++ b/scriptTemplate.R @@ -0,0 +1,68 @@ +# scriptTemplate.R +# +# Purpose: +# Version: +# Date: +# Author: +# +# Input: +# Output: +# Dependencies: +# +# ToDo: +# Notes: +# +# ============================================================================== + +setwd("") + +# ==== PARAMETERS ============================================================ +# Define and explain all parameters. No "magic numbers" in your code below. + + + +# ==== PACKAGES ============================================================== +# Load all required packages. + +if (!require(RUnit, quietly=TRUE)) { + install.packages("RUnit") + library(RUnit) +} + + +# ==== FUNCTIONS ============================================================= + +# Define functions or source external files +source("") + +myFunction <- function(a, b=1) { + # Purpose: + # Describe ... + # Parameters: + # a: ... + # b: ... + # Value: + # result: ... + + # code ... + + return(result) +} + + + +# ==== PROCESS =============================================================== +# Enter the step-by-step process of your project here. Strive to write your +# code so that you can simply run this entire file and re-create all +# intermediate results. + + + + + + +# ==== TESTS ================================================================= +# Enter your function tests here... + + +# [END] diff --git a/taskSolutions.R b/taskSolutions.R new file mode 100644 index 0000000..a8fcd9b --- /dev/null +++ b/taskSolutions.R @@ -0,0 +1,12 @@ +# taskSolutions.R +# +# Code for (some of) the workshop tasks + + + + + + + +# [END] +