24
Installing Optional Packages Bioconductor and S4 Classes Steven Buechler Department of Mathematics 276B Hurley Hall; 1-6233 Fall, 2007

Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Bioconductorand S4 Classes

Steven Buechler

Department of Mathematics276B Hurley Hall; 1-6233

Fall, 2007

Page 2: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Outline

Installing Optional PackagesInstalling BioconductorObjects and Methods in RExpressionSet

Page 3: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Packages Extend R

So far everything we’ve done is in the core R distribution. R canbe extended to handle particular problems through additionalpackages. These aren’t installed with the R application.

Many of the packages we’ll use in microarray analysis are part ofthe Bioconductor system. To use a package like affy you mustfirst install the package on your machine and and execute

> library(affy)

Page 4: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Packages Extend R

So far everything we’ve done is in the core R distribution. R canbe extended to handle particular problems through additionalpackages. These aren’t installed with the R application.

Many of the packages we’ll use in microarray analysis are part ofthe Bioconductor system. To use a package like affy you mustfirst install the package on your machine and and execute

> library(affy)

Page 5: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Install Bioconductor Lite Packages

Bioconductor provides a nice script for installing a default minimalset of packages. You should do this.

> source("http://bioconductor.org/biocLite.R")

> biocLite()

This installs 20 or so packages.

Page 6: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Install Others Through Menus

The R application has a menu item for installing additionalpackages. First browse the website to identify what you want. Onyour own please install the packages

hgu133a, hgu133acdf, hgu133aprobe,hgu133plus2, hgu133plus2cdf, hgu133plus2probe

Bioconductor calls these Metadata packages because it is dataused to get annotation data about Affymetrix probes.

Page 7: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Additional Packages at CRAN

You may have need for R packages developed independently ofBioconductor, like spBayes for ecology. Browse the CRAN site forpackages, download documentation there, and install the packagesthrough the R menu.

Page 8: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Outline

Installing Optional PackagesInstalling BioconductorObjects and Methods in RExpressionSet

Page 9: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Better Classesto represent objects

• The classes we will encounter in Bioconductor packages arestructured around an object-oriented programming paradigmS4 proposed by John Chambers (developer of S).

• Coding objects as lists is contrived and limits functionality.Real object-oriented standards are better, especially with largecomplex biological data objects.

Page 10: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Better Classesto represent objects

• The classes we will encounter in Bioconductor packages arestructured around an object-oriented programming paradigmS4 proposed by John Chambers (developer of S).

• Coding objects as lists is contrived and limits functionality.Real object-oriented standards are better, especially with largecomplex biological data objects.

Page 11: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

OOP: Classes

• A class provides a software abstraction of a real world object.It reflects how we think about certain objects and whatinformation they should contain.

• Classes are defined in terms of slots, which contain therelevant data. These are like the components in a list.

• An object is an instance of a class.

• A class defines the structure, inheritance and initialization ofobjects.

Page 12: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

OOP: Classes

• A class provides a software abstraction of a real world object.It reflects how we think about certain objects and whatinformation they should contain.

• Classes are defined in terms of slots, which contain therelevant data. These are like the components in a list.

• An object is an instance of a class.

• A class defines the structure, inheritance and initialization ofobjects.

Page 13: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

OOP: Classes

• A class provides a software abstraction of a real world object.It reflects how we think about certain objects and whatinformation they should contain.

• Classes are defined in terms of slots, which contain therelevant data. These are like the components in a list.

• An object is an instance of a class.

• A class defines the structure, inheritance and initialization ofobjects.

Page 14: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

OOP: Classes

• A class provides a software abstraction of a real world object.It reflects how we think about certain objects and whatinformation they should contain.

• Classes are defined in terms of slots, which contain therelevant data. These are like the components in a list.

• An object is an instance of a class.

• A class defines the structure, inheritance and initialization ofobjects.

Page 15: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

OOP: Classesaccessing slots

The slots in an object can be accessed in several ways. The classfor microarray expression data is ExpressionSet. The slot in anExpressionSet object containing the matrix of expression values isnamed exprs. If upp1Eset is an ExpressionSet object the exprs slotcan be accessed by any one of the following.

• upp1Eset@exprs

• exprs(upp1Eset), or

• slot(upp1Eset, "exprs")

slotNames(upp1Eset) lists all the slots in this object.

Page 16: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

OOP: Methods

• A method is a function that performs an action on an object.

• Methods define how a particular function should behavedepending on the class of its arguments. (The plot()method behaves differently when you apply it to factors ornumeric vectors.)

• Methods allow computations to be adapted to particular datatypes; i.e., classes.

• Associated to any object is a list of the methods that can beapplied to it.

Page 17: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

OOP: Methods

• A method is a function that performs an action on an object.

• Methods define how a particular function should behavedepending on the class of its arguments. (The plot()method behaves differently when you apply it to factors ornumeric vectors.)

• Methods allow computations to be adapted to particular datatypes; i.e., classes.

• Associated to any object is a list of the methods that can beapplied to it.

Page 18: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

OOP: Methods

• A method is a function that performs an action on an object.

• Methods define how a particular function should behavedepending on the class of its arguments. (The plot()method behaves differently when you apply it to factors ornumeric vectors.)

• Methods allow computations to be adapted to particular datatypes; i.e., classes.

• Associated to any object is a list of the methods that can beapplied to it.

Page 19: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

OOP: Methods

• A method is a function that performs an action on an object.

• Methods define how a particular function should behavedepending on the class of its arguments. (The plot()method behaves differently when you apply it to factors ornumeric vectors.)

• Methods allow computations to be adapted to particular datatypes; i.e., classes.

• Associated to any object is a list of the methods that can beapplied to it.

Page 20: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Getting Help

Espcially when dealing with a number of complex object classes itis important to have good documentation. Writing this is part ofthe standards for packages.

> class?"class name"

gives information about the class including slot names andmethods. Note that if the class is defined in a particular packageyou must load it first with library(),

> library(Biobase)> class?ExpressionSet

(Output suppressed)

Page 21: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Getting Package Help

An overview about a package can be accessed by, e.g.,

> package?Biobase

(Output suppressed) However, the written documentation will bemore complete.

Page 22: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Older Method Help Format

It isn’t always clear what methods can be applied to a class writtenin the old list-like format. To get a list of the methods (functions)that can be applied to an object of class “clsNm”, use

> methods(class = "clsNm")

Conversely, given a generic function, “func”; i.e., one written in thebase R application, a list of the classes to which it can be appliedcan be found with

> methods("func")

You can see, e.g., all the classes that can be used in a plot.

Page 23: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Outline

Installing Optional PackagesInstalling BioconductorObjects and Methods in RExpressionSet

Page 24: Bioconductor - and S4 Classessteve/Rcourse/Lecture9v1.pdf · Installing Optional Packages OOP: Classes • Aclassprovides a software abstraction of a real world object. It re ects

Installing Optional Packages

Learn About the ExpressionSet Class

Read ExpressionSetIntroduction.pdf, documentation in the Biobasepackage available online.