SlideShare uma empresa Scribd logo
1 de 64
Baixar para ler offline
Workshops	
  in	
  next-­‐genera1on	
  
science	
  at	
  UNC	
  Charlo7e	
  2014	
  
Workshop	
  2	
  -­‐	
  R,	
  RStudio,	
  &	
  
reproducible	
  research	
  with	
  knitr	
  
1	
  
 R,	
  RStudio,	
  &	
  reproducible	
  
research	
  with	
  knitr	
  
2	
  
wings	
  2014	
  
No	
  programming	
  experience	
  necessary	
  
"we	
  wanted	
  users	
  to	
  be	
  able	
  to	
  begin	
  in	
  an	
  
interac1ve	
  environment,	
  where	
  they	
  did	
  not	
  
consciously	
  think	
  of	
  themselves	
  as	
  
programming.	
  Then	
  as	
  their	
  needs	
  became	
  
clearer	
  and	
  their	
  sophis1ca1on	
  increased,	
  they	
  
should	
  be	
  able	
  to	
  slide	
  gradually	
  into	
  
programming..."	
  
John	
  Chambers,	
  Stages	
  in	
  the	
  Evolu0on	
  of	
  S	
  
	
  
3	
  
Why	
  use	
  R?	
  
•  Free	
  &	
  open	
  source	
  
•  Has	
  a	
  lot	
  of	
  support	
  	
  
– Popular	
  in	
  many	
  domains	
  (finance,	
  business	
  
analy1cs,	
  sta1s1cs,	
  biology)	
  
•  Many	
  libraries	
  available	
  for	
  biological	
  data	
  
analysis	
  through	
  Bioconductor	
  project	
  	
  
– Such	
  as	
  EdgeR	
  (today)	
  
•  Now	
  has	
  an	
  easy	
  to	
  use,	
  free	
  user	
  interface	
  
called	
  RStudio	
  
4	
  
RStudio	
  
•  A	
  very	
  nice	
  graphical	
  user	
  interface	
  for	
  R.	
  
•  It's	
  free!	
  	
  
•  Integrates	
  well	
  with	
  knitr	
  
– tool	
  for	
  wri1ng	
  sta1s1cal	
  reports	
  w/	
  R	
  markdown	
  
5	
  
R	
  Markdown	
  ".Rmd"	
  	
  
•  Lets	
  you	
  write	
  a	
  report	
  that	
  combines	
  results	
  
and	
  commands	
  	
  
•  Sounds	
  weird,	
  but	
  once	
  you	
  get	
  used	
  to	
  it,	
  it's	
  
very	
  powerful	
  
•  Catch	
  mistakes	
  before	
  publica1on	
  
– Ask	
  a	
  friend	
  to	
  run	
  &	
  review	
  your	
  data	
  analysis	
  	
  
6	
  
knitr	
  &	
  R	
  Markdown	
  enable	
  literate	
  
programming	
  
•  A	
  way	
  to	
  do	
  "literate	
  
programming"	
  	
  
–  Developed	
  by	
  Donald	
  
Knuth,	
  Stanford	
  Computer	
  
Science	
  professor	
  
•  Literate	
  programming:	
  
Write	
  programs	
  that	
  
explain	
  what	
  they	
  are	
  
doing	
  while	
  they	
  are	
  
doing	
  it.	
  
•  Prac1cal	
  applica1on:	
  Data	
  
Analysis	
  Reports	
  
7	
  
Plan	
  for	
  Today	
  
•  Introduce	
  R	
  and	
  RStudio	
  
– Part	
  I:	
  Func1ons	
  &	
  plots	
  
– Part	
  2:	
  Markdown	
  
– Part	
  3:	
  See	
  how	
  sta1s1cal	
  tes1ng	
  works	
  in	
  R	
  
•  Differen1al	
  expression	
  analysis	
  walk-­‐through	
  
(may	
  extend	
  into	
  Workshop	
  3)	
  
•  Goal:	
  Get	
  you	
  started!	
  	
  
– Lots	
  of	
  Web	
  resources	
  for	
  further	
  study	
  
8	
  
Let's	
  get	
  started!	
  
9	
  
Start	
  RStudio	
  
•  RStudio	
  has	
  panes	
  	
  
– w/	
  min,	
  max	
  bu7ons	
  
(top	
  right)	
  
•  Panes	
  have	
  tabs	
  
10	
  
console	
  where	
  you	
  type	
  commands	
   environment,	
  shows	
  
variables	
  you've	
  
defined	
  
Make	
  new	
  project	
  (Part	
  1)	
  
•  Select	
  File	
  >	
  
Project	
  >	
  New	
  
Project	
  ..	
  	
  
•  Choose	
  New	
  
Directory	
  
11	
  
Make	
  new	
  project	
  (Part	
  2)	
  
•  Choose	
  Empty	
  
Project	
  
12	
  
Make	
  new	
  project	
  (Part	
  3)	
  
•  Choose	
  Empty	
  
Project	
  
•  Enter	
  
"wings2014"	
  	
  
•  Click	
  Create	
  
Project	
  
13	
  
Project	
  name	
  in	
  
upper	
  right	
  
corner	
  
14	
  
•  Open	
  folder	
  wings2014	
  
•  See	
  wings2014.Rproj	
  file	
  
•  Tip:	
  Aier	
  quit,	
  double-­‐click	
  to	
  
start	
  RStudio	
  with	
  correct	
  
directory	
  sekngs	
  
15	
  
Enter	
  commands	
  in	
  Console	
  
16	
  
>	
  symbol	
  is	
  
the	
  prompt	
  
•  Type	
  commands	
  or	
  
expressions	
  at	
  the	
  
prompt,	
  ENTER	
  
•  R	
  evaluates	
  what	
  
you	
  type,	
  prints	
  the	
  
result	
  
•  Returns	
  prompt	
  
Prac1ce:	
  Try	
  arithme1c	
  expressions	
  
•  Add	
  +	
  
•  Subtract	
  -­‐	
  
•  Mul1ply	
  *	
  
•  Raise	
  to	
  a	
  power	
  **	
  
17	
  
•  Expressions	
  return	
  values	
  as	
  
one-­‐element	
  vectors.	
  	
  
•  [1]	
  indicates	
  that	
  the	
  value	
  
next	
  to	
  it	
  has	
  this	
  index.	
  
Prac1ce:	
  Save	
  results	
  to	
  variables	
  
18	
  
•  Use	
  '='	
  to	
  assign	
  
result	
  to	
  a	
  variable	
  
– Nothing	
  printed	
  
•  Type	
  variable	
  name	
  
to	
  see	
  what's	
  in	
  it	
  
•  Use	
  variables	
  in	
  
expressions	
  
Variables	
  refer	
  to	
  objects	
  
19	
  
•  Environment	
  tab	
  shows	
  objects	
  created	
  thus	
  far	
  
•  Most	
  of	
  what	
  you	
  do	
  in	
  R	
  involves	
  manipula1ng	
  
objects	
  saved	
  to	
  variable	
  names	
  
– Use	
  objects	
  as	
  inputs	
  to	
  func1ons	
  	
  
R	
  func1ons	
  
•  R	
  has	
  many	
  func1ons	
  
– math	
  
– plokng	
  
– sta1s1cal	
  tests	
  	
  
•  Func1ons	
  take	
  inputs	
  	
  called	
  arguments	
  
•  Most	
  func1ons	
  have	
  many	
  possible	
  
arguments	
  
– Usually	
  have	
  reasonable	
  defaults	
  
20	
  
argument	
  
How	
  to	
  use	
  a	
  func1on	
  in	
  4	
  steps	
  
1.  Type	
  func1on	
  name	
  
2.  Type	
  "("	
  open	
  paren	
  
!  RStudio	
  types	
  closing	
  paren	
  for	
  
you	
  
3.  Type	
  arguments	
  
– if	
  more	
  than	
  one	
  argument,	
  
insert	
  ","	
  (comma)	
  
4.  Type	
  ENTER	
  
21	
  
sqrt	
  calculates	
  
square	
  root	
  	
  
Prac1ce:	
  	
  rnorm	
  func1on	
  	
  	
  
•  rnorm	
  creates	
  a	
  vector	
  of	
  numbers	
  randomly	
  
sampled	
  from	
  normal	
  distribu1on	
  with	
  specified	
  
mean,	
  standard	
  devia1on	
  
22	
  
func1on	
  
name	
  
rnorm(10,5,5)!
	
  
sample	
  
size	
  
mean	
  
standard	
  
devia1on	
  
arguments	
  
Prac1ce:	
  	
  rnorm	
  func1on	
  	
  	
  
•  Mean	
  and	
  standard	
  
devia1on	
  are	
  
op1onal	
  
•  If	
  you	
  don't	
  specify	
  
them,	
  they	
  default	
  
default	
  to:	
  	
  
– 0	
  default	
  mean	
  
– 1	
  default	
  sd	
  
23	
  
R	
  1p!	
  
•  Use	
  UP	
  arrow	
  key	
  to	
  retrieve	
  previous	
  
command	
  
– Saves	
  typing	
  
24	
  
Prac1ce:	
  R	
  allows	
  named	
  arguments	
  
Order	
  can	
  
vary	
  	
  
25	
  
rnorm(10,mean=5,sd=2)!
	
  
26	
  
•  Type	
  help(rnorm)
to	
  list	
  arguments,	
  
defaults	
  
•  help	
  is	
  a	
  func1on	
  
– takes	
  other	
  func1ons	
  as	
  
arguments	
  
help	
  shows	
  how	
  to	
  use	
  a	
  func1on	
  	
  
Now	
  you	
  know	
  how	
  to...	
  
•  Calculate	
  values	
  &	
  see	
  the	
  result	
  	
  
•  Save	
  output	
  to	
  variables	
  
•  Use	
  Environment	
  tab	
  to	
  view	
  variables	
  
•  Use	
  R	
  func1ons	
  	
  
Next	
  -­‐-­‐-­‐	
  ploKng!!!	
  
27	
  
R	
  plokng	
  func1ons	
  
•  Many	
  op1ons	
  
– generic	
  x-­‐y	
  plot,	
  sca7er	
  plots	
  
– barplots	
  
– dendrograms	
  	
  
– histograms	
  ...	
  and	
  much	
  more	
  
•  Highly	
  configurable!	
  
– log	
  or	
  linear	
  scale	
  axes	
  
– different	
  characters	
  or	
  colors	
  for	
  points	
  ...	
  and	
  
much	
  more	
  
28	
  
Prac1ce:	
  Generic	
  x-­‐y	
  plot	
  (sca7er	
  plot)	
  	
  
•  named	
  argument	
  
main	
  determines	
  
plot	
  1tle	
  
•  Note:	
  Enclose	
  text	
  
in	
  quotes	
  	
  
29	
  
Prac1ce:	
  Try	
  other	
  op1ons	
  
•  col	
  -­‐	
  color	
  of	
  points	
  
(in	
  quotes)	
  
•  pch	
  -­‐	
  point	
  character	
  
– numeric	
  code	
  
– le7er	
  (in	
  quotes)	
  	
  
30	
  and	
  many	
  more..	
  
Prac1ce:	
  Histogram	
  (hist)	
  
•  main	
  -­‐	
  plot	
  1tle	
  
(in	
  quotes)	
  	
  
•  col	
  -­‐	
  color	
  of	
  bars	
  
(in	
  quotes)	
  
31	
  
Prac1ce:	
  Adding	
  to	
  a	
  plot	
  (1)	
  
•  abline -­‐	
  "a	
  b	
  line"	
  	
  
–  add	
  straight	
  line	
  
•  Arguments:	
  
–  v	
  or	
  h	
  for	
  loca1on	
  of	
  
ver1cal	
  or	
  horizontal	
  
line	
  
–  a	
  and	
  b	
  for	
  slope	
  and	
  
y	
  intercept	
  	
  
32	
  
Prac1ce:	
  Adding	
  to	
  a	
  plot	
  (2)	
  
•  points 	
  	
  
–  add	
  points	
  to	
  a	
  plot	
  
•  Arguments:	
  
–  x	
  ,	
  y	
  x	
  &	
  y	
  values	
  for	
  
the	
  points	
  	
  
–  other	
  op1ons,	
  same	
  
as	
  for	
  plot !
33	
  
Take-­‐home:	
  In	
  R	
  you	
  can	
  "script"	
  a	
  plot	
  
•  Using	
  plokng	
  commands	
  like	
  points,	
  abline,	
  
lines	
  you	
  can	
  add	
  more	
  data	
  to	
  a	
  plot,	
  element	
  
by	
  element	
  
•  Most	
  plokng	
  commands	
  accept	
  the	
  same	
  
op1ons,	
  like	
  
– pch	
  -­‐	
  point	
  character	
  
– col	
  -­‐	
  color	
  
•  Learning	
  one	
  plokng	
  command	
  helps	
  you	
  
learn	
  many.	
  
34	
  
Prac1ce:	
  Graphics	
  demo	
  
•  Enter	
  
demo(graphics)!
•  Type	
  ENTER	
  to	
  see	
  
next	
  plot	
  
35	
  
Part	
  2	
  -­‐	
  R	
  Markdown	
  
36	
  
How	
  to	
  install	
  knitr	
  
•  Go	
  to	
  Packages	
  tab	
  	
  
•  Not	
  checked?	
  
– Check	
  it	
  
•  Not	
  installed?	
  
– Select	
  Tools	
  >	
  
Install	
  Packages...	
  
– Enter	
  knitr	
  
– Click	
  Install	
  
•  May	
  need	
  to	
  
restart	
  RStudio	
  
37	
  
Setup	
  -­‐	
  to	
  enable	
  be7er	
  coding!	
  	
  
	
  Go	
  to	
  Tools	
  >	
  Global	
  Preferences	
  >	
  Panes	
  
•  Top	
  right:	
  
console	
  
•  Lower	
  right:	
  
Environment,	
  
History,	
  Files,	
  
Plots,	
  Help	
  
•  Top	
  Lei:	
  
Source	
  	
  
•  Lower	
  lei:	
  
everything	
  
else	
  
38	
  
Prac1ce:	
  Make	
  R	
  Markdown	
  file	
  
•  Click	
  "new"	
  file	
  icon	
  
•  Choose	
  R	
  Markdown	
  
– Creates	
  an	
  example	
  R	
  
Markdown	
  
•  Take	
  a	
  moment	
  to	
  
scan	
  document	
  
39	
  
R	
  Markdown	
  has	
  plain	
  text	
  with	
  
formakng	
  instruc1ons	
  
•  Row	
  of	
  "==="	
  makes	
  
"Title"	
  a	
  top	
  level	
  
heading	
  	
  
40	
  
R	
  Markdown	
  has	
  code	
  chunks	
  
•  Code	
  chunk	
  -­‐	
  three	
  
back	
  1cs,	
  {r},	
  ends	
  
with	
  three	
  more	
  
back	
  1cs	
  
•  gray	
  background	
  
41	
  
knitr	
  "knits"	
  code	
  &	
  text	
  
•  Makes	
  an	
  HTML	
  document	
  (web	
  page)	
  that	
  
combines	
  	
  
– code	
  	
  
– output	
  from	
  code	
  
– your	
  text	
  explana1ons	
  
42	
  
Prac1ce:	
  Knit	
  HTML	
  
•  Save	
  the	
  file	
  as	
  
"Example.Rmd"	
  
•  Click	
  
•  Preview	
  appears	
  
•  HTML	
  file	
  appears	
  
•  Click	
  Example.html	
  
in	
  File	
  tab	
  
– choose	
  View	
  in	
  Web	
  
browser	
  	
  	
  	
  
43	
  
knitr	
  makes	
  an	
  HTML	
  document	
  (a	
  
Web	
  page)	
  
•  Images	
  embedded	
  
•  You	
  can	
  email	
  it,	
  save	
  in	
  a	
  Dropbox,	
  etc	
  
44	
  
Prac1ce:	
  Edit	
  Example	
  
•  Edit	
  Plain	
  text	
  
•  Edit	
  code	
  chunks	
  
45	
  
Prac1ce:	
  Run	
  commands	
  in	
  Markdown	
  
•  Put	
  cursor	
  inside	
  
code	
  chunk	
  
•  Type	
  CNTRL-­‐ENTER	
  
– or	
  click	
  run	
  
46	
  
Shortcut:	
  Chunks	
  menu	
  (top	
  right)	
  
•  Put	
  cursor	
  in	
  a	
  chunk	
  
•  Use	
  Run	
  Current	
  Chunk	
  to	
  run	
  en1re	
  chunk	
  
•  Or	
  Run	
  All	
  	
  
47	
  
Prac1ce:	
  Edit	
  Markdown,	
  make	
  plot	
  
look	
  nicer	
  
•  Use	
  col	
  to	
  add	
  color	
  
•  Use	
  las	
  to	
  change	
  orienta1on	
  of	
  y	
  axis	
  
numbers	
  
48	
  
Prac1ce:	
  Run	
  the	
  new	
  code	
  
49	
  
•  Put	
  cursor	
  inside	
  
code	
  chunk	
  
•  Type	
  CNTRL-­‐ENTER	
  
– or	
  click	
  run	
  
Prac1ce:	
  knit	
  your	
  Markdown	
  
50	
  
Sta1s1cal	
  tests	
  in	
  R	
  
•  Tests	
  implemented	
  as	
  func1ons	
  
– Usually	
  return	
  list	
  objects	
  
•  List	
  is	
  
– object	
  that	
  contains	
  other	
  objects	
  of	
  many	
  types	
  
•  Previously,	
  you	
  saw	
  vectors	
  
– Output	
  of	
  rnorm	
  command	
  
– Vectors	
  are	
  like	
  lists	
  that	
  only	
  contain	
  one	
  type	
  of	
  
object	
  (e.g.,	
  numbers	
  only)	
  
51	
  
Prac1ce:	
  Start	
  a	
  new	
  sec1on	
  
•  Heading,	
  smaller	
  than	
  
1tle	
  heading	
  
52	
  
•  Make	
  new	
  code	
  chunk	
  
•  Make	
  new	
  vectors	
  
•  Run	
  t.test!
Tip:	
  Markdown	
  help	
  
•  Using	
  R	
  Markdown	
  opens	
  
Web	
  page	
  w/	
  more	
  info	
  
•  Markdown	
  Quick	
  Reference	
  
shows	
  Markdown	
  codes	
  in	
  
Help	
  tab	
   53	
  
Prac1ce:	
  Run	
  the	
  code	
  
54	
  
•  t.test	
  output	
  is	
  in	
  result!
•  result is	
  a	
  list	
  
•  Cursor	
  inside	
  chunk	
  
•  Type	
  CNTRL-­‐ENTER	
  
– or	
  click	
  run	
  
Prac1ce:	
  Type	
  result	
  (variable	
  
name)	
  in	
  console	
  for	
  a	
  summary	
  
55	
  
Prac1ce:	
  Result	
  is	
  a	
  list	
  with	
  named	
  
components	
  	
  
•  Use	
  names	
  func1on	
  to	
  find	
  what	
  it	
  contains	
  
•  Use	
  $	
  to	
  retrieve	
  named	
  components	
  
56	
  
Differen1al	
  expression	
  analysis	
  
walk-­‐through	
  	
  
Effects	
  of	
  mild	
  chronic	
  heat	
  stress	
  on	
  gene	
  
expression	
  in	
  tomato	
  pollen	
  
	
  
57	
  
Goals	
  
•  Show	
  you	
  how	
  to	
  structure	
  a	
  data	
  analysis	
  
– Useful	
  framework	
  you	
  can	
  use	
  in	
  many	
  sekngs	
  
•  Give	
  you	
  an	
  example	
  differen1al	
  gene	
  
expression	
  analysis	
  for	
  RNA-­‐Seq	
  
– Use	
  it	
  as	
  a	
  star1ng	
  point	
  for	
  other	
  projects	
  
– 	
  Tip:	
  Review	
  edgeR	
  user	
  guide	
  for	
  other	
  example	
  
data	
  analyses	
  
58	
  
Structure	
  of	
  the	
  data	
  analysis	
  
•  Introduc1on	
  
–  explain	
  the	
  experimental	
  design	
  
–  state	
  ques1ons	
  (no	
  more	
  than	
  3,	
  ideally	
  2)	
  
•  Analysis	
  
–  describe	
  steps	
  of	
  analysis,	
  with	
  results	
  
–  explain	
  judgment	
  calls,	
  like	
  P	
  value	
  cutoffs	
  
•  Conclusion	
  
–  answer	
  the	
  original	
  ques1ons	
  
•  State	
  limita1ons	
  of	
  the	
  analysis	
  
•  Session	
  info	
  including	
  soiware	
  versions	
  used	
  
Adapted	
  from	
  Jeff	
  Leek's	
  Data	
  Analysis,	
  Coursera	
  	
  
59	
  
Prac1ce:	
  Setup	
  
•  Go	
  to	
  
h7ps://bitbucket.org/lorainelab/tomatopollen	
  
60	
  
Download	
  repository	
  
61	
  
Move	
  to	
  Desktop	
  
•  Subfolders	
  correspond	
  to	
  analysis	
  chunks	
  
–  See	
  README.md	
  for	
  details	
  
•  Open	
  Differen0alExpression	
  
Folder	
  name	
  suffix	
  based	
  on	
  repo	
  version	
  
62	
  
Double-­‐click	
  ".Rproj"	
  file	
  in	
  Differen1al	
  
Expression	
  folder	
  
•  Opens	
  a	
  new	
  RStudio	
  window	
  	
  
63	
  
Review	
  of	
  the	
  experiment	
  	
  
•  Tomato	
  plants	
  subjected	
  to	
  chronic	
  mild	
  heat	
  
stress	
  &	
  control	
  
–  Greenhouse	
  C	
  	
  
–  Greenhouse	
  B	
  
•  Mature	
  pollen	
  grains	
  harvested	
  in	
  batches	
  over	
  
eight	
  weeks,	
  ~	
  10	
  plants	
  per	
  batch	
  
–  One	
  treatment	
  sample,	
  one	
  control	
  sample	
  per	
  
collec1on	
  
•  RNA	
  extracted,	
  sent	
  to	
  UCLA	
  for	
  sequencing	
  
–  10	
  libraries,	
  5	
  treatments,	
  5	
  controls,	
  69	
  base	
  paired	
  
end	
  sequencing	
  
64	
  Next:	
  Step-­‐by-­‐step	
  walk-­‐through	
  of	
  R	
  Markdown	
  

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Theano tutorial
Theano tutorialTheano tutorial
Theano tutorial
 
Lisp
LispLisp
Lisp
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming Languge
 
Lecture 01 variables scripts and operations
Lecture 01   variables scripts and operationsLecture 01   variables scripts and operations
Lecture 01 variables scripts and operations
 
Gentle Introduction To Lisp
Gentle Introduction To LispGentle Introduction To Lisp
Gentle Introduction To Lisp
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 
CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly CNIT 126 6: Recognizing C Code Constructs in Assembly
CNIT 126 6: Recognizing C Code Constructs in Assembly
 
Introduction to Python Part-1
Introduction to Python Part-1Introduction to Python Part-1
Introduction to Python Part-1
 
Introduction to Programming in LISP
Introduction to Programming in LISPIntroduction to Programming in LISP
Introduction to Programming in LISP
 
358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9
 
Lisp
LispLisp
Lisp
 
The Compatibility Challenge:Examining R and Developing TERR
The Compatibility Challenge:Examining R and Developing TERRThe Compatibility Challenge:Examining R and Developing TERR
The Compatibility Challenge:Examining R and Developing TERR
 
CNIT 126 5: IDA Pro
CNIT 126 5: IDA Pro CNIT 126 5: IDA Pro
CNIT 126 5: IDA Pro
 
CNIT 127 Ch Ch 1: Before you Begin
CNIT 127 Ch Ch 1: Before you BeginCNIT 127 Ch Ch 1: Before you Begin
CNIT 127 Ch Ch 1: Before you Begin
 
Practical Malware Analysis: Ch 5: IDA Pro
Practical Malware Analysis: Ch 5: IDA ProPractical Malware Analysis: Ch 5: IDA Pro
Practical Malware Analysis: Ch 5: IDA Pro
 
Practical Malware Analysis: Ch 6: Recognizing C Code Constructs in Assembly
Practical Malware Analysis: Ch 6: Recognizing C Code Constructs in AssemblyPractical Malware Analysis: Ch 6: Recognizing C Code Constructs in Assembly
Practical Malware Analysis: Ch 6: Recognizing C Code Constructs in Assembly
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence)
 
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
 
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
 
R intro
R introR intro
R intro
 

Semelhante a WiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitr

Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MD
SonaCharles2
 

Semelhante a WiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitr (20)

Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014
 
Advanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAdvanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.ppt
 
Pa2 session 1
Pa2 session 1Pa2 session 1
Pa2 session 1
 
Introduction to R software, by Leire ibaibarriaga
Introduction to R software, by Leire ibaibarriaga Introduction to R software, by Leire ibaibarriaga
Introduction to R software, by Leire ibaibarriaga
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptx
 
How to obtain and install R.ppt
How to obtain and install R.pptHow to obtain and install R.ppt
How to obtain and install R.ppt
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MD
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Introduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics ResearchersIntroduction to R for Learning Analytics Researchers
Introduction to R for Learning Analytics Researchers
 
Python Programming and GIS
Python Programming and GISPython Programming and GIS
Python Programming and GIS
 
Pa1 session 2
Pa1 session 2 Pa1 session 2
Pa1 session 2
 
Best corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiBest corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbai
 
Python
PythonPython
Python
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 

Mais de Ann Loraine

Mais de Ann Loraine (15)

Use Integrated Genome Browser to explore, analyze, and publish genomic data
Use Integrated Genome Browser to explore, analyze, and publish genomic dataUse Integrated Genome Browser to explore, analyze, and publish genomic data
Use Integrated Genome Browser to explore, analyze, and publish genomic data
 
Visualize genomes with Integrated Genome Browser
Visualize genomes with Integrated Genome BrowserVisualize genomes with Integrated Genome Browser
Visualize genomes with Integrated Genome Browser
 
BINF 3121 Data Analysis Report How-To
BINF 3121 Data Analysis Report How-ToBINF 3121 Data Analysis Report How-To
BINF 3121 Data Analysis Report How-To
 
Giving great talks in Bioinformatics - from Professional Communication class ...
Giving great talks in Bioinformatics - from Professional Communication class ...Giving great talks in Bioinformatics - from Professional Communication class ...
Giving great talks in Bioinformatics - from Professional Communication class ...
 
Interviewing - why some questions are off limits
Interviewing - why some questions are off limitsInterviewing - why some questions are off limits
Interviewing - why some questions are off limits
 
RNA-Seq Analysis of Blueberry Fruit Development and Ripening
RNA-Seq Analysis of Blueberry Fruit Development and RipeningRNA-Seq Analysis of Blueberry Fruit Development and Ripening
RNA-Seq Analysis of Blueberry Fruit Development and Ripening
 
Introducing ProtAnnot - Araport workshop at PAG 2016
Introducing ProtAnnot - Araport workshop at PAG 2016Introducing ProtAnnot - Araport workshop at PAG 2016
Introducing ProtAnnot - Araport workshop at PAG 2016
 
Em pcr 16x9
Em pcr 16x9Em pcr 16x9
Em pcr 16x9
 
Arrays and alternative splicing
Arrays and alternative splicingArrays and alternative splicing
Arrays and alternative splicing
 
Visualizing the genome: Techniques for presenting genome data and annotations
Visualizing the genome: Techniques for presenting genome data and annotationsVisualizing the genome: Techniques for presenting genome data and annotations
Visualizing the genome: Techniques for presenting genome data and annotations
 
wings2014 Workshop 1 Design, sequence, align, count, visualize
wings2014 Workshop 1 Design, sequence, align, count, visualizewings2014 Workshop 1 Design, sequence, align, count, visualize
wings2014 Workshop 1 Design, sequence, align, count, visualize
 
RNA-Seq data analysis at wings 2014 - Workshop 3 Biological Interpretation
RNA-Seq data analysis at wings 2014 - Workshop 3 Biological InterpretationRNA-Seq data analysis at wings 2014 - Workshop 3 Biological Interpretation
RNA-Seq data analysis at wings 2014 - Workshop 3 Biological Interpretation
 
Linking IGB with Galaxy
Linking IGB with GalaxyLinking IGB with Galaxy
Linking IGB with Galaxy
 
IGB genome genometry data models by Gregg Helt and Cyrus Harmon
IGB genome genometry data models by Gregg Helt and Cyrus HarmonIGB genome genometry data models by Gregg Helt and Cyrus Harmon
IGB genome genometry data models by Gregg Helt and Cyrus Harmon
 
RNA-Seq analysis of blueberry fruit identifies candidate genes involved in ri...
RNA-Seq analysis of blueberry fruit identifies candidate genes involved in ri...RNA-Seq analysis of blueberry fruit identifies candidate genes involved in ri...
RNA-Seq analysis of blueberry fruit identifies candidate genes involved in ri...
 

Último

Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
nirzagarg
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
gajnagarg
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
gajnagarg
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Klinik kandungan
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
ahmedjiabur940
 
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
gajnagarg
 
Computer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdfComputer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdf
SayantanBiswas37
 
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
Health
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
nirzagarg
 

Último (20)

Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
Gomti Nagar & best call girls in Lucknow | 9548273370 Independent Escorts & D...
 
Statistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbersStatistics notes ,it includes mean to index numbers
Statistics notes ,it includes mean to index numbers
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
 
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
 
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
 
Computer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdfComputer science Sql cheat sheet.pdf.pdf
Computer science Sql cheat sheet.pdf.pdf
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
 
Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubai
 
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Begusarai [ 7014168258 ] Call Me For Genuine Models...
 
20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
 

WiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitr

  • 1. Workshops  in  next-­‐genera1on   science  at  UNC  Charlo7e  2014   Workshop  2  -­‐  R,  RStudio,  &   reproducible  research  with  knitr   1  
  • 2.  R,  RStudio,  &  reproducible   research  with  knitr   2   wings  2014  
  • 3. No  programming  experience  necessary   "we  wanted  users  to  be  able  to  begin  in  an   interac1ve  environment,  where  they  did  not   consciously  think  of  themselves  as   programming.  Then  as  their  needs  became   clearer  and  their  sophis1ca1on  increased,  they   should  be  able  to  slide  gradually  into   programming..."   John  Chambers,  Stages  in  the  Evolu0on  of  S     3  
  • 4. Why  use  R?   •  Free  &  open  source   •  Has  a  lot  of  support     – Popular  in  many  domains  (finance,  business   analy1cs,  sta1s1cs,  biology)   •  Many  libraries  available  for  biological  data   analysis  through  Bioconductor  project     – Such  as  EdgeR  (today)   •  Now  has  an  easy  to  use,  free  user  interface   called  RStudio   4  
  • 5. RStudio   •  A  very  nice  graphical  user  interface  for  R.   •  It's  free!     •  Integrates  well  with  knitr   – tool  for  wri1ng  sta1s1cal  reports  w/  R  markdown   5  
  • 6. R  Markdown  ".Rmd"     •  Lets  you  write  a  report  that  combines  results   and  commands     •  Sounds  weird,  but  once  you  get  used  to  it,  it's   very  powerful   •  Catch  mistakes  before  publica1on   – Ask  a  friend  to  run  &  review  your  data  analysis     6  
  • 7. knitr  &  R  Markdown  enable  literate   programming   •  A  way  to  do  "literate   programming"     –  Developed  by  Donald   Knuth,  Stanford  Computer   Science  professor   •  Literate  programming:   Write  programs  that   explain  what  they  are   doing  while  they  are   doing  it.   •  Prac1cal  applica1on:  Data   Analysis  Reports   7  
  • 8. Plan  for  Today   •  Introduce  R  and  RStudio   – Part  I:  Func1ons  &  plots   – Part  2:  Markdown   – Part  3:  See  how  sta1s1cal  tes1ng  works  in  R   •  Differen1al  expression  analysis  walk-­‐through   (may  extend  into  Workshop  3)   •  Goal:  Get  you  started!     – Lots  of  Web  resources  for  further  study   8  
  • 10. Start  RStudio   •  RStudio  has  panes     – w/  min,  max  bu7ons   (top  right)   •  Panes  have  tabs   10   console  where  you  type  commands   environment,  shows   variables  you've   defined  
  • 11. Make  new  project  (Part  1)   •  Select  File  >   Project  >  New   Project  ..     •  Choose  New   Directory   11  
  • 12. Make  new  project  (Part  2)   •  Choose  Empty   Project   12  
  • 13. Make  new  project  (Part  3)   •  Choose  Empty   Project   •  Enter   "wings2014"     •  Click  Create   Project   13  
  • 14. Project  name  in   upper  right   corner   14  
  • 15. •  Open  folder  wings2014   •  See  wings2014.Rproj  file   •  Tip:  Aier  quit,  double-­‐click  to   start  RStudio  with  correct   directory  sekngs   15  
  • 16. Enter  commands  in  Console   16   >  symbol  is   the  prompt   •  Type  commands  or   expressions  at  the   prompt,  ENTER   •  R  evaluates  what   you  type,  prints  the   result   •  Returns  prompt  
  • 17. Prac1ce:  Try  arithme1c  expressions   •  Add  +   •  Subtract  -­‐   •  Mul1ply  *   •  Raise  to  a  power  **   17   •  Expressions  return  values  as   one-­‐element  vectors.     •  [1]  indicates  that  the  value   next  to  it  has  this  index.  
  • 18. Prac1ce:  Save  results  to  variables   18   •  Use  '='  to  assign   result  to  a  variable   – Nothing  printed   •  Type  variable  name   to  see  what's  in  it   •  Use  variables  in   expressions  
  • 19. Variables  refer  to  objects   19   •  Environment  tab  shows  objects  created  thus  far   •  Most  of  what  you  do  in  R  involves  manipula1ng   objects  saved  to  variable  names   – Use  objects  as  inputs  to  func1ons    
  • 20. R  func1ons   •  R  has  many  func1ons   – math   – plokng   – sta1s1cal  tests     •  Func1ons  take  inputs    called  arguments   •  Most  func1ons  have  many  possible   arguments   – Usually  have  reasonable  defaults   20   argument  
  • 21. How  to  use  a  func1on  in  4  steps   1.  Type  func1on  name   2.  Type  "("  open  paren   !  RStudio  types  closing  paren  for   you   3.  Type  arguments   – if  more  than  one  argument,   insert  ","  (comma)   4.  Type  ENTER   21   sqrt  calculates   square  root    
  • 22. Prac1ce:    rnorm  func1on       •  rnorm  creates  a  vector  of  numbers  randomly   sampled  from  normal  distribu1on  with  specified   mean,  standard  devia1on   22   func1on   name   rnorm(10,5,5)!   sample   size   mean   standard   devia1on   arguments  
  • 23. Prac1ce:    rnorm  func1on       •  Mean  and  standard   devia1on  are   op1onal   •  If  you  don't  specify   them,  they  default   default  to:     – 0  default  mean   – 1  default  sd   23  
  • 24. R  1p!   •  Use  UP  arrow  key  to  retrieve  previous   command   – Saves  typing   24  
  • 25. Prac1ce:  R  allows  named  arguments   Order  can   vary     25   rnorm(10,mean=5,sd=2)!  
  • 26. 26   •  Type  help(rnorm) to  list  arguments,   defaults   •  help  is  a  func1on   – takes  other  func1ons  as   arguments   help  shows  how  to  use  a  func1on    
  • 27. Now  you  know  how  to...   •  Calculate  values  &  see  the  result     •  Save  output  to  variables   •  Use  Environment  tab  to  view  variables   •  Use  R  func1ons     Next  -­‐-­‐-­‐  ploKng!!!   27  
  • 28. R  plokng  func1ons   •  Many  op1ons   – generic  x-­‐y  plot,  sca7er  plots   – barplots   – dendrograms     – histograms  ...  and  much  more   •  Highly  configurable!   – log  or  linear  scale  axes   – different  characters  or  colors  for  points  ...  and   much  more   28  
  • 29. Prac1ce:  Generic  x-­‐y  plot  (sca7er  plot)     •  named  argument   main  determines   plot  1tle   •  Note:  Enclose  text   in  quotes     29  
  • 30. Prac1ce:  Try  other  op1ons   •  col  -­‐  color  of  points   (in  quotes)   •  pch  -­‐  point  character   – numeric  code   – le7er  (in  quotes)     30  and  many  more..  
  • 31. Prac1ce:  Histogram  (hist)   •  main  -­‐  plot  1tle   (in  quotes)     •  col  -­‐  color  of  bars   (in  quotes)   31  
  • 32. Prac1ce:  Adding  to  a  plot  (1)   •  abline -­‐  "a  b  line"     –  add  straight  line   •  Arguments:   –  v  or  h  for  loca1on  of   ver1cal  or  horizontal   line   –  a  and  b  for  slope  and   y  intercept     32  
  • 33. Prac1ce:  Adding  to  a  plot  (2)   •  points     –  add  points  to  a  plot   •  Arguments:   –  x  ,  y  x  &  y  values  for   the  points     –  other  op1ons,  same   as  for  plot ! 33  
  • 34. Take-­‐home:  In  R  you  can  "script"  a  plot   •  Using  plokng  commands  like  points,  abline,   lines  you  can  add  more  data  to  a  plot,  element   by  element   •  Most  plokng  commands  accept  the  same   op1ons,  like   – pch  -­‐  point  character   – col  -­‐  color   •  Learning  one  plokng  command  helps  you   learn  many.   34  
  • 35. Prac1ce:  Graphics  demo   •  Enter   demo(graphics)! •  Type  ENTER  to  see   next  plot   35  
  • 36. Part  2  -­‐  R  Markdown   36  
  • 37. How  to  install  knitr   •  Go  to  Packages  tab     •  Not  checked?   – Check  it   •  Not  installed?   – Select  Tools  >   Install  Packages...   – Enter  knitr   – Click  Install   •  May  need  to   restart  RStudio   37  
  • 38. Setup  -­‐  to  enable  be7er  coding!      Go  to  Tools  >  Global  Preferences  >  Panes   •  Top  right:   console   •  Lower  right:   Environment,   History,  Files,   Plots,  Help   •  Top  Lei:   Source     •  Lower  lei:   everything   else   38  
  • 39. Prac1ce:  Make  R  Markdown  file   •  Click  "new"  file  icon   •  Choose  R  Markdown   – Creates  an  example  R   Markdown   •  Take  a  moment  to   scan  document   39  
  • 40. R  Markdown  has  plain  text  with   formakng  instruc1ons   •  Row  of  "==="  makes   "Title"  a  top  level   heading     40  
  • 41. R  Markdown  has  code  chunks   •  Code  chunk  -­‐  three   back  1cs,  {r},  ends   with  three  more   back  1cs   •  gray  background   41  
  • 42. knitr  "knits"  code  &  text   •  Makes  an  HTML  document  (web  page)  that   combines     – code     – output  from  code   – your  text  explana1ons   42  
  • 43. Prac1ce:  Knit  HTML   •  Save  the  file  as   "Example.Rmd"   •  Click   •  Preview  appears   •  HTML  file  appears   •  Click  Example.html   in  File  tab   – choose  View  in  Web   browser         43  
  • 44. knitr  makes  an  HTML  document  (a   Web  page)   •  Images  embedded   •  You  can  email  it,  save  in  a  Dropbox,  etc   44  
  • 45. Prac1ce:  Edit  Example   •  Edit  Plain  text   •  Edit  code  chunks   45  
  • 46. Prac1ce:  Run  commands  in  Markdown   •  Put  cursor  inside   code  chunk   •  Type  CNTRL-­‐ENTER   – or  click  run   46  
  • 47. Shortcut:  Chunks  menu  (top  right)   •  Put  cursor  in  a  chunk   •  Use  Run  Current  Chunk  to  run  en1re  chunk   •  Or  Run  All     47  
  • 48. Prac1ce:  Edit  Markdown,  make  plot   look  nicer   •  Use  col  to  add  color   •  Use  las  to  change  orienta1on  of  y  axis   numbers   48  
  • 49. Prac1ce:  Run  the  new  code   49   •  Put  cursor  inside   code  chunk   •  Type  CNTRL-­‐ENTER   – or  click  run  
  • 50. Prac1ce:  knit  your  Markdown   50  
  • 51. Sta1s1cal  tests  in  R   •  Tests  implemented  as  func1ons   – Usually  return  list  objects   •  List  is   – object  that  contains  other  objects  of  many  types   •  Previously,  you  saw  vectors   – Output  of  rnorm  command   – Vectors  are  like  lists  that  only  contain  one  type  of   object  (e.g.,  numbers  only)   51  
  • 52. Prac1ce:  Start  a  new  sec1on   •  Heading,  smaller  than   1tle  heading   52   •  Make  new  code  chunk   •  Make  new  vectors   •  Run  t.test!
  • 53. Tip:  Markdown  help   •  Using  R  Markdown  opens   Web  page  w/  more  info   •  Markdown  Quick  Reference   shows  Markdown  codes  in   Help  tab   53  
  • 54. Prac1ce:  Run  the  code   54   •  t.test  output  is  in  result! •  result is  a  list   •  Cursor  inside  chunk   •  Type  CNTRL-­‐ENTER   – or  click  run  
  • 55. Prac1ce:  Type  result  (variable   name)  in  console  for  a  summary   55  
  • 56. Prac1ce:  Result  is  a  list  with  named   components     •  Use  names  func1on  to  find  what  it  contains   •  Use  $  to  retrieve  named  components   56  
  • 57. Differen1al  expression  analysis   walk-­‐through     Effects  of  mild  chronic  heat  stress  on  gene   expression  in  tomato  pollen     57  
  • 58. Goals   •  Show  you  how  to  structure  a  data  analysis   – Useful  framework  you  can  use  in  many  sekngs   •  Give  you  an  example  differen1al  gene   expression  analysis  for  RNA-­‐Seq   – Use  it  as  a  star1ng  point  for  other  projects   –   Tip:  Review  edgeR  user  guide  for  other  example   data  analyses   58  
  • 59. Structure  of  the  data  analysis   •  Introduc1on   –  explain  the  experimental  design   –  state  ques1ons  (no  more  than  3,  ideally  2)   •  Analysis   –  describe  steps  of  analysis,  with  results   –  explain  judgment  calls,  like  P  value  cutoffs   •  Conclusion   –  answer  the  original  ques1ons   •  State  limita1ons  of  the  analysis   •  Session  info  including  soiware  versions  used   Adapted  from  Jeff  Leek's  Data  Analysis,  Coursera     59  
  • 60. Prac1ce:  Setup   •  Go  to   h7ps://bitbucket.org/lorainelab/tomatopollen   60  
  • 62. Move  to  Desktop   •  Subfolders  correspond  to  analysis  chunks   –  See  README.md  for  details   •  Open  Differen0alExpression   Folder  name  suffix  based  on  repo  version   62  
  • 63. Double-­‐click  ".Rproj"  file  in  Differen1al   Expression  folder   •  Opens  a  new  RStudio  window     63  
  • 64. Review  of  the  experiment     •  Tomato  plants  subjected  to  chronic  mild  heat   stress  &  control   –  Greenhouse  C     –  Greenhouse  B   •  Mature  pollen  grains  harvested  in  batches  over   eight  weeks,  ~  10  plants  per  batch   –  One  treatment  sample,  one  control  sample  per   collec1on   •  RNA  extracted,  sent  to  UCLA  for  sequencing   –  10  libraries,  5  treatments,  5  controls,  69  base  paired   end  sequencing   64  Next:  Step-­‐by-­‐step  walk-­‐through  of  R  Markdown