Package 'Mondrian'

Title: A Simple Graphical Representation of the Relative Occurrence and Co-Occurrence of Events
Description: The unique function of this package allows representing in a single graph the relative occurrence and co-occurrence of events measured in a sample. As examples, the package was applied to describe the occurrence and co-occurrence of different species of bacterial or viral symbionts infecting arthropods at the individual level. The graphics allows determining the prevalence of each symbiont and the patterns of multiple infections (i.e. how different symbionts share or not the same individual hosts). We named the package after the famous painter as the graphical output recalls Mondrian’s paintings.
Authors: Aurélie Siberchicot [aut, cre] , Delphine Charif [aut], Gabriel Terraz [aut], Fabrice Vavre [aut]
Maintainer: Aurélie Siberchicot <[email protected]>
License: GPL (>=2.0)
Version: 1.1-1
Built: 2024-11-16 05:20:38 UTC
Source: https://github.com/lbbe-software/mondrian

Help Index


A Simple Graphical Representation of the Relative Occurrence and Co-Occurrence of Events

Description

The unique function of this package allows representing in a single graph the relative occurrence and co-occurrence of events measured in a sample.
As examples, the package was applied to describe the occurrence and co-occurrence of different species of bacterial or viral symbionts infecting arthropods at the individual level. The graphics allows determining the prevalence of each symbiont and the patterns of multiple infections (i.e. how different symbionts share or not the same individual hosts).
We named the package after the famous painter as the graphical output recalls Mondrian’s paintings.

A shiny application MondrianShiny is available to use the functionalities of the Mondrian package in an interactive way. In this application, two examples are shown. The user can also upload its own data and compute the mondrian function on it. The display output can then be saved. MondrianShiny can be run on a R session, doing shiny::runApp(system.file("MondrianShiny", package = "Mondrian")) or online at https://lbbe-shiny.univ-lyon1.fr/Mondrian/inst/MondrianShiny/.

Author(s)

Aurélie Siberchicot <[email protected]>, Delphine Charif, Gabriel Terraz and Fabrice Vavre

See Also

mondrian

Examples

# About using the MondrianShiny app
# 

if(interactive()) {
  shiny::runApp(system.file("MondrianShiny", package = "Mondrian"))
}

Multiple infection profiles in one population

Description

Presence/absence data about 3 endosymbionts in each of 10 individuals belonging to the same population.

Usage

data("endosymbiont_1pop")

Format

A data frame with 10 observations (each individual, in rows) on the following 3 variables (each endosymbiont, in columns): C, H, and W are numeric vectors indicating if the endosymbiont is detected. The presence of a symbiont in an individual is indicated by 1 and its absence by 0.

Examples

data(endosymbiont_1pop)
  
  ## Compute the occurrence table of multiple infection profiles
  rev(table(apply(endosymbiont_1pop, 1, paste, collapse = "")))
  
  ## 110 011 010 
  ##   6   2   2

Multiple infection profiles in three populations

Description

Presence/absence data of 5 endosymbionts in each of 30 individuals belonging to three distinct populations.

Usage

data("endosymbiont_3pop")

Format

A data frame with 30 observations (each individual, in rows) on the following 6 variables (including 5 endosymbionts, in columns): pop is a factor (with 3 levels: AlxT, MalD and MslCh) indicating which of the three populations each individuals belongs and A, C, H, R and W are numeric vectors indicating if the endosymbiont is detected. The presence of a symbiont in an individual is indicated by 1 and its absence by 0.

Examples

data(endosymbiont_3pop)
  table(endosymbiont_3pop$pop)
  
  ## AlxT  MalD MslCh 
  ##   10    10    10

Computes and displays the relative occurrence and co-occurence of events

Description

This function allows representing in a single graph the relative occurrence and co-occurrence of events measured in a sample. As examples, the package was applied to describe the occurrence and co-occurrence of different species of bacterial or viral symbionts infecting arthropods at the individual level. The graphics allows determining the prevalence of each symbiont and the patterns of multiple infections (i.e. how different symbionts share or not the same individual hosts). The graphical output recalls Mondrian’s paintings.

Usage

mondrian(data, labels = colnames(data), xlab = "", ylab = "", main = "", 
    col = NULL , pop = NULL, indiv = FALSE, ...)

Arguments

data

a data frame or a matrix containing the infection profile of each individual for each symbiont. Rows corresponds to individuals and columns to the symbionts.

labels

a vector containing the symbionts name. By default, labels are the columns name of data.

xlab

a string of characters indicating the x-axis label.

ylab

a string of characters indicating the y-axis label.

main

a string of characters indicating the main title of the displayed output. This string is followed by the number of individuals to constitute the actual main title.

col

a vector containing as many colors as symbionts. See Details.

pop

a number index indicating the number of the column containing the population's factor in data. If it is missing, individuals are considering belonging to a unique population and data must not contain a pop column.

indiv

a logical to draw horizontal lines separating each individual profile.

...

graphical parameters. See plot and par.

Details

By default, rectangles' colors come from the Set1 palette defined by the brewer.pal function of the RColorBrewer package. This palette automatically proposes distinct colors (more than 2 and less than 10 values).

Value

The mondrian function yields two outputs:

- a plot representing the occurence and co-occurence of symbionts within individuals, recalling famous Mondrian paintings. Individuals are represented by horizontal lines, and each column represents one symbiont. Horizontal lines (representing individuals) are reordered to optimize the reading. Uninfected individuals are always represented in white. For each column, the coloured area corresponds to the total prevalence of this symbiont. When coloured areas are present in different columns, this indicates co-infection. If individuals belong to different populations (pop is not null), the graphical output is a layout with one display for each sub-population and one display where all individuals are considered belonging to a unique population.

- the distinct profiles of multiple infection and their prevalence (considering all symbionts in data) in the whole population and in each sub-population (when pop is not null).

See Also

brewer.pal

Examples

data(endosymbiont_1pop)
  out1 <- mondrian(endosymbiont_1pop)
  out1
  
  ## 110 011 010 
  ## 0.6 0.2 0.2
  
  
  data(endosymbiont_3pop)
  out2 <- mondrian(endosymbiont_3pop, pop = 1)
  out2
  
  ## $AlxT
  ## 01100 
  ##        1 
  ## $MalD
  ## 10111 10011 01101 00100
  ##   0.1   0.1   0.1   0.7 
  ## $MslCh
  ## 10111 10011 10010 10001 00110 00010
  ##   0.1   0.1   0.4   0.1   0.1   0.2 
  ## $pop
  ##      10111      10011      10010      10001      01101      01100 
  ## 0.06666667 0.06666667 0.13333333 0.03333333 0.03333333 0.33333333 
  ##      00110      00100      00010
  ## 0.03333333 0.23333333 0.06666667
  
  names(out2)
  ## [1] "AlxT"  "MalD"  "MslCh" "pop"