Table of contents for R programming for bioinformatics / Robert Gentleman.


Bibliographic record and links to related information available from the Library of Congress catalog
Note: Electronic data is machine generated. May be incomplete or contain other coding.


Counter
1 Introducing R                                                1
1.1 Introduction ............................                1
1.2 Motivation  .......   .....................             2
1.3  A  note on the text  ... . . ........ .....  .. .   .  ..
1.4 Acknowledgments . .............           ....... ..
2 R Language Fundamentals                                      5
2.1 Introduction ......................... . .
2.1.1  A brief introduction to R  ...................
2.1.2  Attributes  ........... . ...  ....  . .  . . ....  6
2.1.3  A very brief introduction to OOP in R . ........  7
2.1.4  Some special values.............. . . . . .  . . .  8
2.1.5  Types of objects .....  ................         9
2.1.6  Sequence generating and vector subsetting .... ...  11
2.1.7  Types of functions  . ...........  . .  .  .  ....  .  12
2.2  Data  structures  .................    ........    .   1:2
2.2.1  Atomic vectors . . .. . .. ........ .  . . ....  1:2
2.2.2  Numerical computing ........... .......... . .  15
2.2.3  Factors  .........   .................          16
2.2.4  Lists, environments and data frames . ... .. ....  18
2.3  Managing your R session . .. . ..  ........ .... .  .  22
2.3.1  Finding out more about an object . .. .. .  .. ....  24
2.4 Language basics . . . .  ... ............. .      . .   25
2.4.1  Operators ......... .   ...............         26
2.5 Subscripting and subsetting ..........   ..... ...      28
2.5.1  Vector and  matrix subsetting  . ....... .  .  ... .  29
2.6  Vectorized  computations  . ..........  .... .... ..   36
2.6.1  The recycling rule  . . ...... ......  .   . .. .  .  37
2.7 Replacement functions .................. ...            38
2.8 Functional programming . ...................            39
2.9  Writini) functions  ................... .      .   .. .  41
2.10 Flow control . . . . . .  ......... . . . .  ........  42
2.10.1 Conditionals ....... ................ .         44
2.11 Exception handling .........  ...............          45
2.12 Evaluation . . . . . . . . ....................        50
2.12.1  Standard  evaluation  .  .  .  .. ...........   5.1
2.12.2 Non-standard evaluation ... .....  ..... . .  .  52
2.12.3  Fumn tion  eval ation  ................    .    3
2.12.4  [In iirecrt finction  inv cwation  .  ........... .  54
2.12.5  Evalhitionon  'exit  ................. .   .   54
S2. 6 Otrher topics ......    ..............     ....  55
2.12.7 Name spaces . ....           ..................  57
2.13 Lxitnl scope ....               ..........................  359
2.1:3.1 Likelihoodls. .. . .....................       (il
2.13.2  Fu cti(ion optimization  ..................    (62
2.14  ( rap.hics .....             ............................ . . 64
3 Object-Oriented Programming in R                            67
"3.1  [lit rodu(lltic   . . ... .................  .  .  .. .  67
3.2  11he iasics of OOP . ................... ...          i68
3.2. 1  lileritance.  .  .  .  .  .            .   .. . !69
3.2.2  Dispatch . . ..................... ...          71
3.2.3  Al,stact dalta types  . . . . . ........ ..... . . 72
3.2.4  Self-dlescribing da.ta...  . ... . . . . .  . ......73
.3 S3 ()()P . . .      ........ ........... .  .......     74
3.3.1  Implicit classes  .................    .  . .   7(i
3.3.2  Explresiion data example .  ....... . .  . . .  77
3.3.3  S:  generic filnctions and metliods . ...........  78
3.3.4  Details of (lispatch . . ..................     8 i
3.3.5 (;routp genervics .................... ..       83
3.3.6i S3 ieplacemeniit metllods. . . . .  .............  83
3.4 S O)P . . . . .. ................... .            ... . :
3. 1. 1 (lsses... ... .................. ....
3.4.2  Types of classes . . . . . . . . ... . . . .  . .  .  8
3. 4.:  Atritltes . . .  .......................       98
3.4.  ('Class unions  .... ................      . .   99
3.4.5  Acce,ss(or  fuictionts  .  .  .  .  .  ...  . ..  .  .  ...   .  .  .  .  1((
3. 4.16  sing  S3  classes with  S4  classes . . .. .. ...  ....  t(00
13.7  SJ genleric f1u1chtions and  methods . . . . . . . . .  . . .  1.01
3.1.8  The syntax of Ilmethod declaratio,l  .... ..  . . . . .  105
3.4.9  The  sen niitic: s of method  inv at io  .  .  . .  . .  .  .  . .  l()0(i
3.l4.1()  Replac eitm eitt  imetho .  .  .  .  .  .  .  . .  . . . .  .   .... .  1()7
3.4.11 PFinling methlodls . . . . ..................  1)7
3.4.12 Advanced topics . ................... 1.08
3.5   si[   cl2 ssmes amul mtpithc,l s in  a.ckags  .  . . . .  . . . .  110
3.6 D1clmlgi,nlassione an . ........  ........ . .  . . . .  11()
3.6.1  Fnitli g doclimentai ion  . . .  .  .   .    I 10
3.6.2 NWritilg dIHiu(leint,atiotn .................   111
3.7  D)v,Wggiig ... ...  ...........     . . .  ...... .  11
3.'s  Maingiti  S3 S3 n Sa 4  tA,gh ther.  . . . ...............  112
3..1  (Gettting  andl sertitig  the  class attribtlte  ..  . .. . .  .  113
3.8.2  N[ixiig  S3  anl  $4  mlethods  .  .  .  .  . .  .  .  ...   .  .  11-1
3.9  Navigating the class and Ithod hierarhy. . . . . ...  115
4 Input and Output in R                                       119
4.1  Iutroduction  .  . . . . . . . . . . . . . . . . . . .  .   .   .   .   119
.2  Basic file handling ...          . . . .       . .  .  120
4.2.1  Viewinlg  files        .          . . .  ..  . .  124
4.2.2  File manipulation .  ..................         125
4.2.3 iVorkig with R's binar format . . . . . . . .  . . . .  129
1.3 Connect ions . . ................... ....           .  130
4.3.1  Text comnectionis .....    .............. ..    131
4.3.2  Interprocess( comiiunicatioun.  . . ... ..  . .  .  ..   . . .  133
1.3.3  Seek  . ........   ..... . .     . . .    .   .  136
4.1  File input and output  ...................        ... . 137
4.4.1  Reading rectangular data ................       138
4.4.2  Writing (ldata  ............      ..........    139
4.4.3  Debian Control Format (DCF) .............       140
4.4.4  FASTA Format ... . . ...... . . . . . .  . . . .  141
4.5 Source anrd sink: capturing R output . .  . . .  . . .  . . 142
4.6 Tools for accessing files on the Internet . ............  143
5 Working with Character Data                                 145
5.1  Introluction  ...................      .  .  .  ..... .  145
5.2  Builtin  capabilities  ..... ..............      ... .  1-16
5.2.1  Modcifying text  .            . . . .   . . . .  151
5.2.2  Sorting and comparing .... .... . . ... . . .. ...  152
5.2.3  Matching a set of alternatives . .. . . .. ..... .. .  153
5.2.4  Forimatting text and  inmbers . . .. . .........  155
5.2.5  Special characters and escaping . .... . . .  . .  . ..  155
5.2.6  Parsing and dleparsing . ...... .. . . . .  . . .....  158
5.2.7  Plottiing with text ....... . . . . ..... .......  159
5.2.8  Locale and ft encoding . . . . ..... . .  .  .  ..... .  159
5.3  Regular expressions ...................        .....  159
5.3. 1  Regular expression  basics  .. . . .  . . .  .. .. ..  . .  160
5.3.2  Matching ..............             ...........  166
5.3.3  Using regular expressions . . . . ........... ..  167
5.3.4  Globbing and regular expressiols ... . . . .  . .  . .  169
5.4  Prefixes, suffixes and  substrings  . ..  ... . .  ..  .  .  .  .   .  169
5.5  Biological sequences  . ...................      .  . .  171
5.5.1  Encoding geiiomnes.s .....  ................    172
5.6  Matching  patterns  ...................       .... .   173
5.6.1  Matchlig single query seqences . . . .......... ..  174
5.6.2  Matching many query sequences . ....  ..... .   175
5.6.3  Palindromes and paired matches . . . . . .  . ... ....  177
5.6.4  Aligmnients . . ........... ...........         179
6  Foreign Language Interfaces                                183
6.1  [utroduction  .  .  . . . . . . . . . . . . . . . . . . .  .   .   .   . .  183
6. 1. 1  O verview  .  .  . . . . . . . . . . . . . . . . . .  . ... .  181
6.1.2  The C programmning language  ... .  .    . . . .  15
6.2  Calling C mid FORTRAN from R  . . . . . . ........     185
6.2.1   C  aind  .Fortran  . .       .  .  ..  . . . .. .  186
6.2.2 U(sing .Call and .External . . . . . . . ........ 187
3.3  Wriling C  code to interface with  . .....  . ..  . ..   . . . .  188
6.3. 1  Hegistering routines . .................        88
t.3.2  Dealini with pecial values . . . . . ........   ....... 19
6.3.3  Siingle Irecision . . . . . . . . . . ............191
6.3. 1  Matrices and  arrays  . ..  . . .  .  . ...  . . . .  191
6.3.5  Allowinl  interrllupts .  ........ . . .  ... . .  193
6..6  Error handlin  . ................... . . .       193
6.3.7  H  internals  ..................       ......   193
6.3.S  S4 )OP in C      . . . . . . .  . .... . .  . . . ...  197
6.3. 9  Calling R  from  C ........... ..  ....... .    !)98
6i.4  'sing  the  R  API  ................   ........    .  198
6.4.1  Header files  . . . . ....  ....  . ............ .  198
6.4.2  Sorting  ...................           . . . .  199
6.4.3  Random   unmbers . . . . . . . .         .    .....199
6.5  Lo;ding librariess . . . ................... ..... 202
6.5. 1  Inspecting  DILs  ............ ........     .  203
6.6 Advlanced topics ................ .          ....... 204
6.6.1  External references and ffinalizers .. . .  .  .  ......  2(4
6.6.2  Evaluatilg R expIressions frlom C' . ........... 206
6.7 Other languages .....    ...............        .....  209
7 R Packages                                                  211
7.1 Package basics ............       .............        212
7.1.1 i hle search path  . .... .  ................    212
7.1.2  Package infLrn,mtion . . ... . .. .........  .  213
7.1.3  Data  and  emo..  .  .  .  .  .  .  .  .  .  .  . .  ...  .  .  .  .  .  .  215
7.1.41  Vig llettes  .   .  .  .  .  .  .   .          215
7.2  Package manangement .  . . . . .  . . . . ..  ...  . . . . . ..  216
7.2.1  biocViews . . . .............. .         .....  218
7.2.2  Managing libraries  .   . . . .  . . .   .    ......219
7.3  Pack;age authoring  .  . . .  . . .  .       .......  219
7.3.1  The DESCRIPTION  file  . . . . ............. .  .  ..  22(1
7.3.2  R code . ..................          ....... 220
7.3.3  Documentat ion ....... ........   ..........    221
7.3.-  Namre spaces . .            .......... ......  .. .. ..224
7.3.  Finding out about name spaces  . . . . . .  . . .  . . . .  226
7.4 Initialization  . .................. .  . . .   . . . . 226
7. 4.1  Event hooks ..................        ......   227
8 Data Technologies                                          229
8.1  Introduction  .  . . . . . . . . . . . . .  .  .  .  . .  .  .   .   .   .   .  229
8.1.1  A  brief description of GO  ... . . .  . . . . . .  .  229
8.2 Using R for data manipulation . . . . .......... . .230
8.2.1  Aggregation and creating tables . . .. . ..... ...  230
8.2.2  Apply functions . . . . . .  . . . . ............. . ... 232
8.2.3  Efficient apply-like functions .. . . .. ..... ...  234
8.2.4  Combining and reshaping rectangular data .. . ....  234
8.3 Example .... .................. .            ...... 236
8.4 Database technologies .        ....... . .  . . ..... ... 238
8.4.1  DBI  ....  ........... ............         .  239
8.4.2  SQLite ................. .......... 241
8.4.3  Using AnnotationDbi . . . . . . .   ..........243
8.5  XNIL  ................   ..    ..........        .. .254
8.5.1  Simple XPath .     . . . .  . . ....... ... 256
8.5.2  The XML package .... . .... . .  . . . ...... .. 257
8.5.3  Handlers ..................       .......   .  257
8.5.4  Example data . . ..... . .  . . .. . ....... . 2258
8.5.5  DONI parsing  ........... ............ 258
8.5.6  XML  event parsing  . ...........  .   .......  261
8.5.7  Parsing HTML  .................           .. . .  263
8.6 Bioinfornmatic resources on the \VWWN  .  . . . . . . . ...  264
8.6.1  PubMed . . .................... ... 265
8.6.2  NCBI  .............. ............           .  265
8.6.3  biomaRt . . . . . . .................  ....... 266
8.6.4  Getting data, from GEO . . ........ .  .. .. . 270
8.6.5  KEGG ..  .............. . .       .........    272
9 Debugging and Profiling                                    273
9.1  Introduction .................           ....... ..   273
9.2  The browser function ..... ..... .. . . .  ...  ..  .. . .  274
9.2.1  A sample browser session ....... .  ........   275
9.3 Debugging in R ..............        .........      . 276
9.3.1 Rluntime debugging ................... . 277
9.3.2  Warnings and other exceptions ......  .......  278
9.3.3  Interactive debugging  . .  ..  ....  .  ...... .  279
9.3.4  The debug and undebug functions . . .... . .  . . .. 281
9.3.5  The trace function .        . . .......  . . . . 285
9.4 Debugging C and other foreign code .... .. . ..... .. 289
9.5 Profiling R code . . ..... . .. . . . ............ 290
9.5.1  Timings      .........       . . . . . . ....  292
9.6  Managing menmory  . . . . . . .................  . . .  .  ....  293
9.6.1  Memory profiling  . . ..  . ... . .  ........... . .  294
9.6.2  Profiling memory allocation  . ... .. .  ....  .. . ..  295
9.6.3  Tracking a single object . . . ............... .298



Library of Congress subject headings for this publication: Bioinformatics, R (Computer program language)