Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Itmat pcbi-r-course-1


Published on

First part of 3-part course on teaching the R statistical package.

  • Be the first to comment

  • Be the first to like this

Itmat pcbi-r-course-1

  1. 1. Intro to using R for Bioinformatics: Part 1 : The Basics<br />Angel Pizarro<br /><br />
  2. 2. Injecting a bit of reality<br />
  3. 3. Taking it a bit further…<br />Waxing floors is not fun, and may not seem relevant, but have some faith Daniel-san<br />
  4. 4. Outline<br />We will teach you some basic uses of R<br />“Do & Tell” method where you will be asked to do an exercise and once done, we will explain what just happened.<br />Will cover basics, plotting and microarray analysis<br />We will not teach you statistics.<br />
  5. 5. What is ?<br />R is a language and environment for statistical computing and graphics. <br />– <br />You can do stuff like this<br />
  6. 6. Install & Run R<br />You should have already installed R, but if you had trouble please see us after class <br />Start R<br />On Windows, use Tinn-R<br />On Mac, use the source R application<br />On Linux, use the console<br />
  7. 7. Help is plentiful<br />Help in three ways<br />Too much! Get me out!<br />
  8. 8. More Help<br />help.start()<br />Start an HTML help session<br />help(mean)<br />Looks up the mean() function's help page<br />?mean <br /> <br />Displays all help pages that contain text “mean”<br />??mean <br />
  9. 9. Whet your appetite…<br />
  10. 10. The Basics<br />Please enter each of the following lines into your R session:<br />
  11. 11.
  12. 12.
  13. 13.
  14. 14. Basic Algebra<br />You will also see this form:<br />
  15. 15. Variables<br />“x” and “y” are variables. <br />They are pointers to some value<br />They can also be pointers to some function<br />
  16. 16. Vectors<br />Enter this in your session:<br />Results<br />
  17. 17. Small tangent: What is “c (1,2,3)”?<br />Use the help()<br />
  18. 18. Accessing Vector Members<br />In R, Vectors start indexes at 1. Most programming languages start indexing at zero<br />Also, NOT WHAT YOU THINK IT IS! It is a INDEX VECTOR, meaning that you access the members of a vector with a vector<br />
  19. 19. Small Tangent 2: Creating Sequences<br />Create regular sequences using a colon<br />Colon has high operator precedence<br />Also see the seq() function<br />
  20. 20. Vectors<br />Are a list of items of the same data type<br />Short for “double precision floating point number”<br />
  21. 21. Doing Stuff with Vectors<br />Math operations occur on each element in sequence<br />Returns a vector of the same size <br />
  22. 22. Factors<br />Simply a vector of items that mean something<br />Disease classifications, drug dosage, US states, months, hapmap ethnic group<br />Can be ordered<br />Can have multiple levels<br />GO Functions<br />
  23. 23. Array and Matrix<br />Multi-dimensional generalizations of vectors<br />k-dimensions where k > 0<br />Assigned by the dim attribute<br />Can be indexed by two or more indices<br />If a single index value (can be a vector) is given, then dim is ignored and underlying vector values are accessed directly<br />Unless the given index values is also an array<br />Matrix is a two-dimensional array<br />
  24. 24. Example<br />An INDEX ARRAY<br />
  25. 25. List<br />An ordered collection of named components<br />
  26. 26. List Access<br />
  27. 27. Data Frame<br />Bastard step child of List and Matrix<br />Essentially a list of vectors of same length<br />Closest representation to an Excel file in R<br />Easiest way to make one is to read in a CSV file<br />
  28. 28.
  29. 29.
  30. 30. Functions<br />We’ve already used them<br />Functions take in arguments and perform some action using those arguments. <br />Actions do not affect the input arguments<br />
  31. 31. Example<br />
  32. 32. Write to CSV file<br />Extra column of the row indices<br />
  33. 33. Save your work!<br />R keeps track of your data and functions<br />You can start from where you left off if you save these to some file<br />
  34. 34. Start from your save point<br />