File: Bimap.Rd

package info (click to toggle)
r-bioc-annotationdbi 1.68.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 8,476 kB
  • sloc: sql: 10,876; makefile: 3; sh: 2
file content (255 lines) | stat: -rw-r--r-- 6,949 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
\name{Bimap}
\docType{class}

\alias{Bimap}

% Classes

\alias{Bimap}
\alias{class:Bimap}
\alias{Bimap-class}

\alias{AnnDbBimap}
\alias{class:AnnDbBimap}
\alias{AnnDbBimap-class}

\alias{GoAnnDbBimap}
\alias{class:GoAnnDbBimap}
\alias{GoAnnDbBimap-class}

\alias{Go3AnnDbBimap}
\alias{class:Go3AnnDbBimap}
\alias{Go3AnnDbBimap-class}

\alias{GOTermsAnnDbBimap}
\alias{class:GOTermsAnnDbBimap}
\alias{GOTermsAnnDbBimap-class}

\alias{AnnDbMap}
\alias{class:AnnDbMap}
\alias{AnnDbMap-class}

\alias{IpiAnnDbMap}
\alias{class:IpiAnnDbMap}
\alias{IpiAnnDbMap-class}

\alias{AgiAnnDbMap}
\alias{class:AgiAnnDbMap}
\alias{AgiAnnDbMap-class}

\alias{ProbeAnnDbBimap}
\alias{class:ProbeAnnDbBimap}
\alias{ProbeAnnDbBimap-class}

\alias{ProbeGo3AnnDbBimap}
\alias{class:ProbeGo3AnnDbBimap}
\alias{ProbeGo3AnnDbBimap-class}

\alias{ProbeAnnDbMap}
\alias{class:ProbeAnnDbMap}
\alias{ProbeAnnDbMap-class}

\alias{ProbeIpiAnnDbMap}
\alias{class:ProbeIpiAnnDbMap}
\alias{ProbeIpiAnnDbMap-class}


% Standard generic methods

\alias{show,FlatBimap-method}
\alias{show,AnnDbBimap-method}

\alias{summary,Bimap-method}
\alias{summary,AnnDbBimap-method}


\title{Bimap objects and the Bimap interface}

\description{
  What we usually call "annotation maps" are in fact Bimap objects.
  In the following sections we present the bimap concept and the
  Bimap interface as it is defined in AnnotationDbi.
}

\section{Display methods}{
  In the code snippets below,
  \code{x} is a Bimap object.

  \describe{
    \item{}{
      \code{show(x)}:
      Display minimal information about Bimap object \code{x}.
    }

    \item{}{
      \code{summary(x)}:
      Display a little bit more information about Bimap object \code{x}.
    }
  }
}

\section{The bimap concept}{
  A bimap is made of:
  \preformatted{
  - 2 sets of objects: the left objects and the right objects.
    All the objects have a name and this name is unique in
    each set (i.e. in the left set and in the right set).
    The names of the left (resp. right) objects are called the
    left (resp. right) keys or the Lkeys (resp. the Rkeys).
  }
  \preformatted{   
  - Any number of links (edges) between the left and right
    objects. Note that the links can be tagged. In our model,
    for a given bimap, either none or all the links are tagged.
  }

  In other words, a bimap is a bipartite graph.

  Here are some examples:
  \preformatted{
  1. bimap B1:

     4 left objects (Lkeys): "a", "b", "c", "d"
     3 objects on the right (Rkeys): "A", "B", "C"

     Links (edges):
      "a" <--> "A"
      "a" <--> "B"
      "b" <--> "A"
      "d" <--> "C"

     Note that:
       - There can be any number of links starting from or ending
         at a given object.
       - The links in this example are untagged.
  }
  \preformatted{
  2. bimap B2:

     4 left objects (Lkeys): "a", "b", "c", "d"
     3 objects on the right (Rkeys): "A", "B", "C"

     Tagged links (edges):
       "a" <-"x"-> "A"
       "a" <-"y"-> "B"
       "b" <-"x"-> "A"
       "d" <-"x"-> "C"
       "d" <-"y"-> "C"

     Note that there are 2 links between objects "d" and "C":
     1 with tag "x" and 1 with tag "y".
  }
}

\section{Flat representation of a bimap}{
  The flat representation of a bimap is a data frame. For
  example, for B1, it is:
  \preformatted{
    left  right
       a      A 
       a      B
       b      A
       d      C
  }
  If in addition the right objects have 1 multivalued attribute,
  for example, a numeric vector:
  \preformatted{
    A <-- c(1.2, 0.9)
    B <-- character(0)
    C <-- -1:1
  }
  then the flat representation of B1 becomes:
  \preformatted{
    left  right  Rattrib1
       a      A       1.2
       a      A       0.9
       a      B        NA
       b      A       1.2
       b      A       0.9
       d      C        -1
       d      C         0
       d      C         1
  }
  Note that now the number of rows is greater than the number
  of links!
}

\section{AnnDbBimap and FlatBimap objects}{
  An AnnDbBimap object is a bimap whose data are stored in a data base.
  A FlatBimap object is a bimap whose data (left keys, right keys and
  links) are stored in memory (in a data frame for the links).
  Conceptually, AnnDbBimap and FlatBimap objects are the same (only
  their internal representation differ) so it's natural to try to define
  a set of methods that make sense for both (so they can be manipulated
  in a similar way). This common interface is the Bimap interface.

  Note that both AnnDbBimap and FlatBimap objects have a read-only
  semantic: the user can subset them but cannot change their data.
}

\section{The "flatten" generic}{
  \preformatted{
    flatten(x) converts AnnDbBimap object x into FlatBimap
    object y with no loss of information
  }
  Note that a FlatBimap object can't be converted into an AnnDbBimap
  object (well, in theory maybe it could be, but for now the data bases
  we use to store the data of the AnnDbBimap objects are treated as
  read-only). This conversion from AnnDbBimap to FlatBimap is performed
  by the "flatten" generic function (with methods for AnnDbBimap objects
  only). 
}

\section{Property0}{
  The "flatten" generic plays a very useful role when we need to
  understand or explain exactly what a given Bimap method f will do when
  applied to an AnnDbBimap object. It's generally easier to explain what
  it does on a FlatBimap object and then to just say "and it does the
  same thing on an AnnDbBimap object". This is exactly what Property0
  says:
  \preformatted{
    for any AnnDbBimap object x, f(x) is expected to be
    indentical to f(flatten(x))
  }
  Of course, this implies that the f method for AnnDbBimap objects
  return the same type of object than the f method for FlatBimap objects.
  In this sense, the "revmap" and "subset" Bimap methods are particular
  because they are expected to return an object of the same class as
  their argument x, so f(x) can't be identical to f(flatten(x)). For
  these methods, Property0 says:
  \preformatted{
    for any AnnDbBimap object x, flatten(f(x)) is expected to
    be identical to f(flatten(x))
  }

  Note to the AnnotationDbi maintainers/developpers: the \code{checkProperty0}
  function (AnnDbPkg-checker.R file) checks that Property0 is satisfied on all
  the AnnDbBimap objects defined in a given package (FIXME: checkProperty0 is
  currently broken).
}

\section{The Bimap interface in AnnotationDbi}{
  The full documentation for the methods of the Bimap interface is splitted
  into 4 man pages: \link{Bimap-direction}, \link{Bimap-keys}
  and \link{Bimap-toTable}.
}

\seealso{
  \link{Bimap-direction},
  \link{Bimap-keys},
  \link{Bimap-toTable},
  \link{BimapFormatting},
  \link{Bimap-envirAPI}
}

\examples{
  library(hgu95av2.db)
  ls(2)
  hgu95av2GO # calls the "show" method
  summary(hgu95av2GO)
  hgu95av2GO2PROBE # calls the "show" method
  summary(hgu95av2GO2PROBE)
}

\keyword{classes}
\keyword{interface}