R: Extract an adjacency matrix from a larger data frame

get_edges {ggmuller} | R Documentation

## Extract an adjacency matrix from a larger data frame

### Description

Extract an adjacency matrix from a larger data frame

### Usage

    get_edges(df, generation = NA)

### Arguments

`df` | Dataframe inclduing column names "Identity", "Parent", and either "Generation" or "Time"
`generation` | Numeric value of Generation (or Time) at which to determine the adjacency matrix (defaults to final time point)

### Value

A dataframe comprising the adjacency matrix.

### Author(s)

Rob Noble, robjohnnoble@gmail.com

### See Also

`get_population_df`

### Examples

    edges <- get_edges(example_df)

    # extract the adjacency matrix from the data frame:
    pop_df <- get_population_df(example_df)

    # create data frame for plot:
    Muller_df <- get_Muller_df(edges, pop_df)

    require(RColorBrewer) # for the palette

    # draw plot:
    num_cols <- length(unique(Muller_df$RelativeFitness)) + 1
    Muller_df$RelativeFitness <- as.factor(Muller_df$RelativeFitness)
    Muller_plot(Muller_df, colour_by = "RelativeFitness",
                palette = rev(colorRampPalette(brewer.pal(9, "YlOrRd"))(num_cols)),
                add_legend = TRUE)

[Package ggmuller version 0.5.1 Index]