[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ micropan  (version  1.0  ) ](/packages/micropan/versions/1.0)

#  rarefaction: Rarefaction curves for a pan-genome

##  Description

Computes rarefaction curves for a number of random permutations of genomes.

##  Usage

    
    
    rarefaction(pan.matrix,n.perm=1)

##  Arguments

pan.matrix

A ` Panmat ` object, see ` [ panMatrix
](/link/panMatrix?package=micropan&version=1.0) ` for details.

n.perm

The number of random genome orderings to use. If  n.perm=1  the fixed order of
the genomes in  pan.matrix  is used.

##  Value

This function returns a ` Rarefac ` object, which is a small extension to a
matrix. The generic functions ` [ plot.Rarefac
](/link/plot.Rarefac?package=micropan&version=1.0) ` , ` [ summary.Rarefac
](/link/summary.Rarefac?package=micropan&version=1.0) ` and ` [ str.Rarefac
](/link/str.Rarefac?package=micropan&version=1.0) ` are available for such
objects.

##  Details

A rarefaction curve is simply the cumulative number of unique gene clusters we
observe as more and more genomes are being considered. The shape of this curve
will depend on the order of the genomes. This function will typically compute
rarefaction curves for a number of (  n.perm  ) orderings. By using a large
number of permutations, and then averaging over the results, the effect of any
particular ordering is smoothed away. The averaged curve illustrates how many
new gene clusters we observe for each new genome. If this levels out and
becomes flat, it means we expect few, if any, new gene clusters by sequencing
more genomes. The function ` [ heaps
](/link/heaps?package=micropan&version=1.0) ` can be used to estimate
population openness based on this principle.

##  See Also

` [ heaps ](/link/heaps?package=micropan&version=1.0) ` , ` [ panMatrix
](/link/panMatrix?package=micropan&version=1.0) ` , ` [ plot.Rarefac
](/link/plot.Rarefac?package=micropan&version=1.0) ` , ` [ summary.Rarefac
](/link/summary.Rarefac?package=micropan&version=1.0) ` , ` [ str.Rarefac
](/link/str.Rarefac?package=micropan&version=1.0) ` .

##  Examples

[ Run this code
](https://www.datacamp.com/datalab/preview?_tag=rdocs&rdocsPath=packages%2Fmicropan%2Fversions%2F1.0%2Ftopics%2Frarefaction&utm_source=r-docs&utm_medium=docs&utm_term=rarefaction&utm_content=run_example_in_datalab)

    
    
    # Loading two Panmat objects in the micropan package
    data(list=c("Mpneumoniae.blast.panmat","Mpneumoniae.domain.panmat"),package="micropan")
    
    # Rarefaction based on a BLAST clustering Panmat object
    rarefac.blast <- rarefaction(Mpneumoniae.blast.panmat,n.perm=100)
    plot(rarefac.blast)
    
    # Rarefaction based on domain sequence clustering Panmat object
    rarefac.domains <- rarefaction(Mpneumoniae.domain.panmat,n.perm=1000)
    summary(rarefac.domains)
    

Run the code above in your browser using  [ DataLab
](https://www.datacamp.com/datalab/preview?_tag=rdocs&rdocsPath=packages%2Fmicropan%2Fversions%2F1.0%2Ftopics%2Frarefaction&utm_source=r-docs&utm_medium=docs&utm_term=rarefaction&utm_content=run_example_in_datalab)

Powered by  [ DataCamp ](https://www.datacamp.com/)