join_metadata: Add metadata to long distance matrix

Description Usage Arguments Details Examples

Description

This functions takes the output from dist_long, plus a data.frame with metadata, and attaches it to the data.frame output from dist_long. It uses a column in the metadata data.frame as a key to join the two data.frames. So, it requires a column of data in the metadata data.frame to have same ID labels as those in the pairwise comparison table.

Usage

1
2
join_metadata(dist, meta, isolate = "ISOLATES", group = "CLUSTER",
  remove_ind = TRUE, measure_col_contains = "dist")

Arguments

dist

A data.frame produced by dist_long function

meta

A data.frame with one column of IDs that match the IDs in dist_long

isolate

A character string with the name of the column in the meta data.frame with the ID data

group

A character string with the name of column containing the grouping variable

remove_ind

A boolean whether to remove all non-essential columns

measure_col_contains

A character string with a pattern that matches up with the measurement columns you wish to retain in the final output (default: 'dist')

Details

The output from dist_long with an additional column containing a factor, with levels composed of joining the categories in the group colum of the metadata data.frame for each pairwise comparison. For example, if one row has distance between samples id1 and id2, and in the grouping column of the metadata id1 is identified as part of group 'A', and id2 is identified as part of group 'B', then the output from that row will 'AB'. If they were from the same group, say 'A', the output would be just 'A'. In this way it is easy to identify pairs of isolates that are from the same group, and pairs of isolates that are from different groups.

Examples

1
2
3
4
5
6
7
## Not run: 
data(woodmouse)
data(woodmouse_meta)
dist_df <- dist_long(woodmouse)
join_metadata(dist_df, woodmouse_meta, isolate = 'SAMPLE_ID', group = 'CLUSTER', remove_ind = TRUE)

## End(Not run)

andersgs/harrietr documentation built on May 12, 2019, 2:41 a.m.