| Title: | Venn and Euler area-proportional diagrams |
|---|---|
| Description: | A package for drawing various species of Venn diagrams. |
| Authors: | Jonathan Swinton |
| Maintainer: | Jonathan Swinton <[email protected]> |
| License: | GPL |
| Version: | 3.1.0.9000 |
| Built: | 2026-05-21 08:00:15 UTC |
| Source: | https://github.com/bedapub/Vennerable |
A package for drawing various species of Venn diagrams.
| Package: | Vennerable |
| Version: | 1.0 |
| LazyLoad: | yes |
| Depends: | graph, RBGL, grid, lattice, RColorBrewer, reshape |
| License: | GPL |
| Built: | R 2.9.0; ; 2009-07-09 13:52:22 UTC; windows |
Index:
Venn Construct intersections of sets Venn-class Class "Venn" ~~~
Further information is available in the following vignettes:
Venn |
(source, pdf) |
Jonathan Swinton
Maintainer: Jonathan Swinton <[email protected]>
Given a Venn object on 4 sets, returns an VennDrawing object rendering it
in the Lewis Carroll style.
compute.S4(V, doWeights = FALSE, s = 0.25, likeSquares = TRUE)compute.S4(V, doWeights = FALSE, s = 0.25, likeSquares = TRUE)
V |
A |
doWeights |
Must be |
s |
If |
likeSquares |
If |
The placement of the face names is not ideal for some combinations with .
An object of class VennDrawing
Jonathan Swinton ([email protected])
compute.S4(Venn(n=4))compute.S4(Venn(n=4))
Given an object of class Venn, compute an appropriate diagram.
compute.Venn(V, doWeights = TRUE, doEuler = FALSE, type)compute.Venn(V, doWeights = TRUE, doEuler = FALSE, type)
V |
An object of class |
doWeights |
Logical |
doEuler |
Logical |
type |
One of |
For more details see the package vignette with vignette("Venn")
An object of class VennDrawing
Jonathan Swinton ([email protected])
setList <- strsplit(month.name,split="") names(setList) <- month.name compute.Venn(Venn(setList[1:3]))setList <- strsplit(month.name,split="") names(setList) <- month.name compute.Venn(Venn(setList[1:3]))
Fills the area of a VennDrawing universe that is not occupied by any set.
PlotDarkMatter(VD)PlotDarkMatter(VD)
VD |
An object of class |
This works by filling the entire universe with grey (not currently changeable) and then plotting then filling the inside of the dark matter boundary with white.
Executed for its side effecrs
Jonathan Swinton ([email protected])
VD <- compute.Venn(Venn(n=2)) PlotDarkMatter(VD)VD <- compute.Venn(Venn(n=2)) PlotDarkMatter(VD)
This is the function called by the plot generic for objects of class VennDrawing.
PlotVennGeometry(C3, gpList, show = list(FaceText = "weight"))PlotVennGeometry(C3, gpList, show = list(FaceText = "weight"))
C3 |
An object of class |
gpList |
A list of lists of graphical parameters. The |
show |
A list of options controlling what is shown. Defaults are |
The algorithm for displaying face annotation is pretty crude. The annotation corresponding to each member of the
FaceText vector is displayed on a single line. weight and signature display the associated
weight and signature for the face. sets produces a concatenated version of the names of the sets in the face,
while elements does the same for the elements; both of these only really work for single character set names or elements.
Jonathan Swinton ([email protected])
library(Vennerable) setList <- strsplit(month.name,split="") names(setList) <- month.name C3 <- compute.Venn(Venn(setList[1:3])) PlotVennGeometry(C3,show=list(FaceText="signature"),gp=VennThemes(C3,colourAlgorithm="signature"))library(Vennerable) setList <- strsplit(month.name,split="") names(setList) <- month.name C3 <- compute.Venn(Venn(setList[1:3])) PlotVennGeometry(C3,show=list(FaceText="signature"),gp=VennThemes(C3,colourAlgorithm="signature"))
Data on the genes which bind to each of three transcription factors (and a fourth which may also be a transcription factor)
data(StemCell)data(StemCell)
A named list with four elements named OCT4, SOX2, NANOG and E2F4.
Each element is a character vector containing the names of 600-1700 associated genes.
Taken from supplementary information in Boyer et al, "Core transcriptional regulatory circuitry in human embryonic stem cells",
Cell, 2005, 122:947–956, 10.1016/j.cell.2005.08.020,http://www.ncbi.nlm.nih.gov/pubmed/16153702.
library(Vennerable) data(StemCell) plot(Venn(Sets=StemCell),type="squares",doWeights=FALSE)library(Vennerable) data(StemCell) plot(Venn(Sets=StemCell),type="squares",doWeights=FALSE)
A class used internally to implement polygon-polgyon clipping
The class describes diagrams which are constructed by superposing simple polygons (ie those with no holes or self-intersections), called Sets. If the Sets are filled with semi-transparent colours, the resulting diagram will have different regions or Faces depending on the intersections between the sets. The boundaries of these regions will not necessarily be simple. (For example one circle may have two other circles nested inside it). A simple model for this process is superpsosing Sets made out of tissue paper, hence the name of the class, which was nearly called a MAGDrawing after the perspex and lightbox exhibit in the children's gallery of the Manchester Art Gallery. which also acted as a prototype.
Points where the Sets intersect are always identified and named within the object.
Sets which partially share a common boundary are defined not to intersect on that common boundary,
so there are only a finite number of intersection points. Each Face contains at least one
named point so additional named points will be introduced for each Face that has no other intersections.
In addition, named points may be introduced to make some of the hidden-line alogorithms easier.
These additional named points can be removed (sometimes) with the function remove.nonintersectionpoints
which leaves the remaining points as the nodes of the graph defined by the Set intersections.
Set and Face boundaries are made up of named edges, each of which starts and finishes at the named points.
Each edge can be either a polygonal segment or a sector of a circle. All of the Faces
in a TissueDrawing are connected to each other (ie the graph is connected), if necessary
by adding invisible edges which are not part of the boundary of any set.
Objects can be created by calls to the functions newTissueFromPolygon() or
newTissueFromCircle, and combined with the function addSetToDrawing).
setList:Named "list", with names given by the name of each Set. Each entry is a character vector of edge names
nodeList:Named "list", with a 1x2 numeric matrix of $(x,y)$ coordinates for each named point.
recentChanges:Nasty bodge slot required by internal algorithms
edgeList:A TDEdgeList, a named list of TDedgeDrawn objects defining the geometry of each edge
faceList:A TDFaceList, a named "list", with one element for each correspondingly named face, listing the edges of that face in clockwise order
faceSignature:Named "list", with names the same as faceList, giving the signature for the face.
Class "TDEdgeList", directly.
Class "TDFaceList", directly.
signature(drawing = "TissueDrawing"): Displays the faces of the drawing on the current graphics device
signature(drawing = "TissueDrawing"): Displays the named points of the drawing
signature(drawing = "TissueDrawing"): Displays the Set boundaries of the drawing
signature(object = "TissueDrawing"): Prints a summary of the drawing
Adding even two overlapping simple polygons together can result in multiple
intersections regions. Finding the boundaries of these intersections,
keeping track of which have come from which combination of sets, and, in particular, coping with
faces embedded inside outher faces is the problem of polygon-polygon clipping.
This class is designed to solve that problem for the combinations of Sets used
in the Vennerable package. It is not designed as a general clipping tool, and
can be very slow, particular for clipping of general polygons. For example, the four ellipse
plot is currently implemented as a combination of many short-segment polygons and several minutes
to run.
Care is taken to keep track of the outside boundary of all of the sets, or equivalently the inside boundary of the 'dark matter', the Face defined as the region where none of the Sets intersect. Nevertheless this portion of the code is currently quite buggy and this can lead to errors in some computed diagrams.
Jonathan Swinton, [email protected]
showClass("TissueDrawing")showClass("TissueDrawing")
Given a collection of Sets, Venn will compute all possible
combinations of intersections and return an object of class Venn, storing the combinations as well
as the number of elements in each intersection (the 'weights').
It will also accept a specification of the weights directly,
or simply of the number of sets desired.
Venn(Sets, Weight, SetNames, numberOfSets) Weights(object) Weights(object) <- valueVenn(Sets, Weight, SetNames, numberOfSets) Weights(object) Weights(object) <- value
Sets |
A list, each element of which can be a list defining the members of a Set |
Weight |
A named vector of weights to associate with each possible combination of Set intersections.
Ignored if |
SetNames |
A character vector of names for each Set. Ignored if |
numberOfSets |
An integer for the number of Sets. Ignored if |
object |
An object of class |
value |
An object like |
An object of class Venn
Jonathan Swinton ([email protected])
Venn(n=3) data(StemCell) w <- Venn(Sets=StemCell[1:2]) Weights(w) # nb order of intersection subsets not guaranteed Weights(w) <- 1:4 Venn(SetNames=letters[1:5])Venn(n=3) data(StemCell) w <- Venn(Sets=StemCell[1:2]) Weights(w) # nb order of intersection subsets not guaranteed Weights(w) <- 1:4 Venn(SetNames=letters[1:5])
A class for intersecting multiple sets together
Objects should be created by calls to the function Venn
IndicatorWeight:Object of class "matrix"
IntersectionSets:Object of class "list". This may be empty.
signature(x = "Venn"): ...
signature(object = "Venn"): ...
signature(x = "Venn", y = "missing"): ...
signature(object = "Venn"): ...
signature(object = "Venn"): ...
Jonathan Swinton ([email protected])
showClass("Venn")showClass("Venn")
Precomputed data on the geometrical structure of various types of Venn diagrams.
data(VennDiagrams)data(VennDiagrams)
A list with elements named battle,AWFEscale,AWFE,
and ellipses. Each element is itself a list in which the nth element, if not NULL, is an object of
class TissueDrawing representing an example of an unweighted Venn diagram on n sets of the given type.
This is really a device to cache the diagrams and is not for direct use. Use eg compute.Venn(Venn(n=...),type=... which returns a plottable object of class VennDrawing instead.
Created by the buildVennDiagrams() function within Vennerable
data(VennDiagrams) TD <- VennDiagrams[["ellipses"]][[4]] class(TD)data(VennDiagrams) TD <- VennDiagrams[["ellipses"]][[4]] class(TD)
A geometrical representation of a Venn diagram suitable for display
Objects can be created by calls of the form new("VennDrawing",V,TD)
where V is an object of class Venn and TD is an object of class TissueDrawing which
has representations for all the Sets and Faces corresponding to the sets and intersections of the V object.
As well as bringing together the geometric and set-theoretic properties of the Venn diagram, this class stores information about the universe in which to display the diagram and provides a number of methods for plotting the final figure.
universe:A matrix with the and coordinates of the bounding universe. Currently assumed to have 2 rows by much of the code, corresponding to the lower left and upper right corners of a bounding rectangle
SetLabels:A data.frame encoding the positions of labels for the Sets
FaceLabels:A data.frame encoding the positions of labels for the Faces
setList:nodeList:recentChanges:edgeList:faceList:faceSignature:IndicatorWeight:See Venn-class
IntersectionSets:See Venn-class
Class "TissueDrawing", directly.
Class "Venn", directly.
Class "TDEdgeList", by class "TissueDrawing", distance 2.
Class "TDFaceList", by class "TissueDrawing", distance 2.
signature(object = "VennDrawing"): Returns the area of each named face
signature(object = "VennDrawing"): ...
signature(x = "VennDrawing", y = "missing"): ...
signature(object = "VennDrawing"): ...
signature(object = "VennDrawing"): ...
signature(object = "VennDrawing"): ...
signature(object = "VennDrawing"): ...
Jonathan Swinton ([email protected])
showClass("VennDrawing")showClass("VennDrawing")
As well as a number of internal helper functions, Vennerable includes code for doing polygon-polygon clipping in some (buggy) generality which may be documented if there is demand.
Jonathan Swinton ([email protected])
Embedded within a VennDiagram object are instructions for displaying annotation
for the sets and their faces. Retrieve them so they can be edited
and re-embedded for subsequent display.
VennGetSetLabels(object) VennSetSetLabels(object, SetLabels) VennGetFaceLabels(object) VennSetFaceLabels(object, FaceLabels) VennGetUniverseRange(object) VennSetUniverseRange(object, universe)VennGetSetLabels(object) VennSetSetLabels(object, SetLabels) VennGetFaceLabels(object) VennSetFaceLabels(object, FaceLabels) VennGetUniverseRange(object) VennSetUniverseRange(object, universe)
object |
An object of class |
SetLabels |
A data.frame. The format of this data.frame may change. |
FaceLabels |
A data.frame. The format of this data.frame may change. |
universe |
An |
Jonathan Swinton ([email protected])
data(StemCell) Vstem <- Venn(StemCell) Vstem3 <- Vstem[,c("OCT4","SOX2","NANOG")] Cstem3 <- compute.Venn(Vstem3,doWeights=TRUE) plot(Cstem3) # don't like the default position of 'SOX2'? SetLabels <- VennGetSetLabels(Cstem3) SetLabels[SetLabels$Label=="SOX2","x"] <- 12 Cstem3 <- VennSetSetLabels(Cstem3,SetLabels) grid::grid.newpage() plot(Cstem3)data(StemCell) Vstem <- Venn(StemCell) Vstem3 <- Vstem[,c("OCT4","SOX2","NANOG")] Cstem3 <- compute.Venn(Vstem3,doWeights=TRUE) plot(Cstem3) # don't like the default position of 'SOX2'? SetLabels <- VennGetSetLabels(Cstem3) SetLabels[SetLabels$Label=="SOX2","x"] <- 12 Cstem3 <- VennSetSetLabels(Cstem3,SetLabels) grid::grid.newpage() plot(Cstem3)
Given a VennDrawing object, which it consults to find the names of each of the sets and faces
in the drawing, returns a list suitable as the gp argument in a subsequent call
to the VennDrawing method for plot.
VennThemes(drawing, colourAlgorithm, increasingLineWidth)VennThemes(drawing, colourAlgorithm, increasingLineWidth)
drawing |
An object of class |
colourAlgorithm |
Missing or one of |
increasingLineWidth |
Logical, defaul |
Set boundary colours are taken from the Set1 palette provided by the RColorBrewer package.
If colourAlgorithm="signature", face fill colours are taken frome the RColorBrewer YlOrRed
palette based on the number of sets represented in the face, so eg all the faces corresponding to membership of a single set are pale yellow while the face corresponding to all the intersections is dark red.
If colourAlgorithm="binary", faces are blue if they correspond to an odd number of intersections and white otherwise.
If colourAlorithm="sequential", each face is given a different colour from the
RColorBrewer Set3 palette, although this is repeated if necessary if there are more faces than the length of this palette (9).
Different faces with the same signature will be given the same colour.
If not specified, sequential is used if there are less than 9 faces, otherwise
signature.
If increasingLineWidth=TRUE, each Set is given a different linewidth, with the last to be plotted given the thinnest width, to help in
visualising nonsimple Venn diagrams.
A list with four elements
Face |
Named list of graphical parameters which will be applied to faces with corresponding names |
FaceText |
Named list of graphical parameters which will be applied to annotation in faces with corresponding names |
Set |
Named list of graphical parameters which will be applied to sets with corresponding names |
FaceText |
Named list of graphical parameters which will be applied to annotation in sets with corresponding names |
These are graphical parameters in the sense of the grid package.
Jonathan Swinton ([email protected])
See also RColorBrewer
# change the name of one set to red text and enlarge the other C2 <- compute.Venn(Venn(n=2)) gp <- VennThemes(C2) gp[["SetText"]][["Set1"]]$col <- "red"; gp[["SetText"]][["Set2"]]$cex <- 2; plot(C2,gp=gp) # use highlevel arguments gp <- VennThemes(C2,colourAlgorithm="binary") plot(C2,gp=gp) gp <- VennThemes(C2,increasingLineWidth=TRUE) plot(C2,gp=gp)# change the name of one set to red text and enlarge the other C2 <- compute.Venn(Venn(n=2)) gp <- VennThemes(C2) gp[["SetText"]][["Set1"]]$col <- "red"; gp[["SetText"]][["Set2"]]$cex <- 2; plot(C2,gp=gp) # use highlevel arguments gp <- VennThemes(C2,colourAlgorithm="binary") plot(C2,gp=gp) gp <- VennThemes(C2,increasingLineWidth=TRUE) plot(C2,gp=gp)