Package 'hagis'

Title: Analysis of Plant Pathogen Pathotype Complexities, Distributions and Diversity
Description: Analysis of plant pathogen pathotype survey data. Functions provided calculate distribution of susceptibilities, distribution of complexities with statistics, pathotype frequency distribution, as well as diversity indices for pathotypes. This package is meant to be a direct replacement for Herrmann, Löwer and Schachtel's (1999) <doi:10.1046/j.1365-3059.1999.00325.x> Habgood-Gilmour Spreadsheet, 'HaGiS', previously used for pathotype analysis.
Authors: Austin G. McCoy [aut, ccp] , Zachary Noel [aut, ccp] , Adam H. Sparks [aut, cre] , Martin Chilvers [aut, ths] , Jari Oksanen [aut] (Contributed fix for the use of 'vegan' in betadiversity vignette.), Zhian N. Kamvar [ctb, rev] , Michigan Soybean Promotion Committee [fnd], Project GREEEN [fnd], North Central Soybean Research Program [fnd], Grains Research and Development Corporation [fnd] (GRDC Project DAQ00186), Grains Research and Development Corporation [fnd, cph] (GRDC Project CUR2210-005OPX (AAGI-CU))
Maintainer: Adam H. Sparks <[email protected]>
License: MIT + file LICENSE
Version: 4.0.0
Built: 2025-02-05 05:20:38 UTC
Source: https://github.com/openplantpathology/hagis

Help Index


Plot hagis Complexities Objects

Description

Creates a ggplot2 object of the frequency of complexity (percent per complexity) or a ggplot2 object of the distribution (number per complexity) calculated by calculate_complexities().

Usage

## S3 method for class 'hagis.complexities'
autoplot(object, type, color = NULL, order = NULL, ...)

Arguments

object

a hagis complexities object generated by calculate_complexities(). Character.

type

a vector of values for which the bar plot is desired. Specify whether to return a graph of the frequency of complexities as a percentage, "percentage", or as the count, "count". Character.

color

a named or hexadecimal color value to use for the bar color

order

sort the x-axis of the bar chart by ascending or descending order of frequency. Accepts ascending or descending input values. Defaults to complexity value. Character.

...

passed to the chosen geom(s)

Value

A ggplot2 object

Examples

# Using the built-in data set, `P_sojae_survey`
data(P_sojae_survey)

# calculate susceptibilities with a 60 % cutoff value
complexities <- calculate_complexities(
  x = P_sojae_survey,
  cutoff = 60,
  control = "susceptible",
  sample = "Isolate",
  gene = "Rps",
  perc_susc = "perc.susc"
)

# Visualize the distribution (count or actual values)
autoplot(complexities, type = "count")

# Visualize the frequency (percentages)
autoplot(complexities, type = "percentage")

Plot hagis Summary Objects

Description

Creates a ggplot2 object of the gene summaries calculated by summarize_gene()

Usage

## S3 method for class 'hagis.gene.summary'
autoplot(object, type, color = NULL, order = NULL, ...)

Arguments

object

a hagis.gene.summary object generated by summarize_gene(). Character.

type

a vector of values for which the bar plot is desired. Specify whether to return a graph of the percent pathogenic isolates, percentage, or as the count, count. Character.

color

a named or hexadecimal color value to use for the bar color

order

sort the x-axis of the bar chart by ascending or descending order of N_virulent_isolates or percent_pathogenic. Accepts ascending or descending input values. Defaults to gene name. Character.

...

passed to the chosen geom(s)

Value

A ggplot2 plot

Examples

# Using the built-in data set, `P_sojae_survey`
data(P_sojae_survey)

# calculate susceptibilities with a 60 % cutoff value
susc <- summarize_gene(
  x = P_sojae_survey,
  cutoff = 60,
  control = "susceptible",
  sample = "Isolate",
  gene = "Rps",
  perc_susc = "perc.susc"
)

# Visualize the summary of genes
autoplot(susc, type = "percentage")

Calculate Distribution of Complexities by Sample

Description

Calculate the distribution of susceptibilities by sample id.

Usage

calculate_complexities(x, cutoff, control, sample, gene, perc_susc)

Arguments

x

a data.frame containing the data.

cutoff

value for percent susceptible cutoff. Numeric.

control

value used to denote the susceptible control in the gene column. Character.

sample

column providing the unique identification for each sample being tested. Character.

gene

column providing the gene(s) being tested. Character.

perc_susc

column providing the percent susceptible reactions. Character.

Value

An object of class hagis.complexities.

An object of class hagis.complexities is a list containing the following components

grouped_complexities

a data.table::data.table() object of grouped complexities

individual_complexities

a data.table::data.table() object of individual complexities

Examples

# Using the built-in data set, `P_sojae_survey`
data(P_sojae_survey)

P_sojae_survey

# calculate susceptibilities with a 60 % cutoff value
complexities <- calculate_complexities(
  x = P_sojae_survey,
  cutoff = 60,
  control = "susceptible",
  sample = "Isolate",
  gene = "Rps",
  perc_susc = "perc.susc"
)
complexities

summary(complexities)

Calculate Diversities Indices

Description

Calculate five pathogen diversity indices.

Diversity indices include:

  • Simple diversity index, which will show the proportion of unique pathotypes to total samples. As the values gets closer to 1, there is greater diversity in pathoypes within the population. Simple diversity is calculated as:

    D=NpNsD = \frac{Np}{Ns}

    where NpNp is the number of pathotypes and NsNs is the number of samples.

  • Gleason diversity index, an alternate version of Simple diversity index, is less sensitive to sample size than the Simple index.

    D=(Np1)log(Ns)D = \frac{ (Np - 1) }{ log(Ns)}

    Where NpNp is the number of pathotypes and NsNs is the number of samples.

  • Shannon diversity index is typically between 1.5 and 3.5, as richness and evenness of the population increase, so does the Shannon index value.

    D=i=1RpilogpiD = -\sum_{i = 1}^{R} p_i \log p_i

    Where pip_i is the proportional abundance of species ii.

  • Simpson diversity index values range from 0 to 1, 1 represents high diversity and 0 represents no diversity. Where diversity is calculated as:

    D=i=1Rpi2D = \sum_{i = 1}^{R} p_i^2

  • Evenness ranges from 0 to 1, as the Evenness value approaches 1, there is a more even distribution of each pathoype's frequency within the population. Where Evenness is calculated as:

    D=Hlog(Np)D = \frac{H'}{log(Np) }

    where HH' is the Shannon diversity index and NpNp is the number of pathotypes.

Usage

calculate_diversities(x, cutoff, control, sample, gene, perc_susc)

Arguments

x

a data.frame containing the data.

cutoff

value for percent susceptible cutoff. Numeric.

control

value used to denote the susceptible control in the gene column. Character.

sample

column providing the unique identification for each sample being tested. Character.

gene

column providing the gene(s) being tested. Character.

perc_susc

column providing the percent susceptible reactions. Character.

Value

A hagis.diversities object.

A hagis.diversities object is a list containing:

  • Number of Samples

  • Number of Pathotypes

  • Simple Diversity Index

  • Gleason Diversity Index

  • Shannon Diversity Index

  • Simpson Diversity Index

  • Evenness Diversity Index

Examples

# Using the built-in data set, P_sojae_survey
data(P_sojae_survey)

P_sojae_survey

# calculate susceptibilities with a 60 % cutoff value
diversities <- calculate_diversities(
  x = P_sojae_survey,
  cutoff = 60,
  control = "susceptible",
  sample = "Isolate",
  gene = "Rps",
  perc_susc = "perc.susc"
)

diversities

Create Binary Data Matrix From Pathotype Data

Description

Creates a binary data matrix from pathotype data representing the pathotype of each isolate. This binary data matrix can be used to visualize beta-diversity of pathotypes using vegan and ape.

Usage

create_binary_matrix(x, cutoff, control, sample, gene, perc_susc)

Arguments

x

a data.frame containing the data.

cutoff

value for percent susceptible cutoff. Numeric.

control

value used to denote the susceptible control in the gene column. Character.

sample

column providing the unique identification for each sample being tested. Character.

gene

column providing the gene(s) being tested. Character.

perc_susc

column providing the percent susceptible reactions. Character.

Value

a binary matrix of pathotype data

Examples

# Using the built-in data set, `P_sojae_survey`
data(P_sojae_survey)

P_sojae_survey

# calculate susceptibilities with a 60 % cutoff value
final_matrix <- create_binary_matrix(x = P_sojae_survey,
                                    cutoff = 60,
                                    control = "susceptible",
                                    sample = "Isolate",
                                    gene = "Rps",
                                    perc_susc = "perc.susc")
final_matrix

Custom Print for hagis Diversities Tables

Description

Print the frequency table of diversities from a hagis.diversities object The resulting object is a pander table (a text object for Markdown) for ease of use in reporting and viewing in the console.

Usage

diversities_table(x, ...)

Arguments

x

a hagis.diversities object generated by calculate_diversities()

...

other arguments passed to pander::panderOptions()

Value

A pander object of diversities

See Also

calculate_diversities(), individual_pathotypes()

Examples

# Using the built-in data set, P_sojae_survey
data(P_sojae_survey)

P_sojae_survey

# calculate susceptibilities with a 60 % cutoff value
diversities <- calculate_diversities(
  x = P_sojae_survey,
  cutoff = 60,
  control = "susceptible",
  sample = "Isolate",
  gene = "Rps",
  perc_susc = "perc.susc"
)

# print the diversities table
diversities_table(diversities)

Prints Individual Pathotypes for Each Sample

Description

Print an object from a hagis.diversities object with individual pathotypes, i.e. each sample's pathotype. The resulting object is a pander table (a text object for Markdown) for ease of use in reporting and viewing in the console.

Usage

individual_pathotypes(x, ...)

Arguments

x

a hagis.diversities object generated by calculate_diversities()

...

other arguments passed to pander::panderOptions()

Value

A pander object of individual pathotypes

See Also

calculate_diversities(), diversities_table()

Examples

# Using the built-in data set, P_sojae_survey
data(P_sojae_survey)

P_sojae_survey

# calculate susceptibilities with a 60 % cutoff value
diversities <- calculate_diversities(
  x = P_sojae_survey,
  cutoff = 60,
  control = "susceptible",
  sample = "Isolate",
  gene = "Rps",
  perc_susc = "perc.susc"
)

# print the diversities table
individual_pathotypes(diversities)

Phytophthora sojae Survey Example Data

Description

Data from a Phytophthora sojae survey

Usage

data(P_sojae_survey)

Format

An object of class data.table with 294 observations of 12 variables

Isolate

P. sojae isolate identifier

Line

Soybean cultivar

Rps

Rps gene identifier

Total

Total number of plants inoculated

HR (1)

Number of plants that exhibit a hypersensitive response after inoculation

Lesion (2)

Number of plants that develop a lesion at inoculation site

Lesion to cotyledon (3)

Number of plants that develop a lesion, which advances to the hypocotyl of the seedling after infection

Dead (4)

Number of dead plants that are observed after inoculation

total.susc

The total number of susceptible plants (Lesion+Lesion to cotyledon+Dead)

total.resis

The total number of resistant plants (equal to HR value)

Source

Data from an ongoing 2017 Phytophthora sojae survey in Michigan, conducted by A. G. McCoy et al..

Examples

data(P_sojae_survey)
P_sojae_survey

Phytophthora sojae Survey Example Metadata

Description

Metadata to accompany internal data from a Phytophthora sojae survey used for an example in the "Beta-diversity Analyses" vignette.

Usage

data(sample_meta)

Format

An object of class data.frame with 21 observations of 2 variables

Sample

P. sojae sample identifier

Locale

US State where sample was collected, limited to Michigan

Source

Data from an ongoing 2017 Phytophthora sojae survey in Michigan, conducted by A. G. McCoy et al..

Examples

data(sample_meta)
sample_meta

Calculate and Summarize Distribution of Susceptibilities by Gene

Description

Calculate the distribution of susceptibilities by gene.

Usage

summarize_gene(x, cutoff, control, sample, gene, perc_susc)

Arguments

x

a data.frame containing the data.

cutoff

value for percent susceptible cutoff. Numeric.

control

value used to denote the susceptible control in the gene column. Character.

sample

column providing the unique identification for each sample being tested. Character.

gene

column providing the gene(s) being tested. Character.

perc_susc

column providing the percent susceptible reactions. Character.

Value

a hagis.gene.summary object.

An object of class hagis.gene.summary is a
data.table::data.table() containing the following components columns

gene

the gene

N_virulent_isolates

the total number virulent isolates for a given gene in the gene column

percent_pathogenic

the frequency with which a gene is pathogenic

Examples

# Using the built-in data set, `P_sojae_survey`
data(P_sojae_survey)

P_sojae_survey

# calculate susceptibilities with a 60 % cutoff value
susc <- summarize_gene(
  x = P_sojae_survey,
  cutoff = 60,
  control = "susceptible",
  sample = "Isolate",
  gene = "Rps",
  perc_susc = "perc.susc"
)
susc