Description Usage Arguments Value Details Examples
View source: R/make_prey_part.R
The function make_prey_part partitions a prey library into clusters
based on user specifications informed by the results of a call to the
function dimac.
| 1 | make_prey_part(sig, clust, n_clust)
 | 
| sig | A matrix of scaled signatures ready for analysis, intended to be
the object  | 
| clust | A data frame containing cluster definitions, intended to be the
object  | 
| n_clust | An integer vector constructed by the user to specify the number of clusters into which each prey type should be partitioned. | 
A list containing the following elements:
A character vector of the partitioned type of each signature.
A character vector of the unique sample ID of each signature.
The number of unique types in the partitioned library.
A character vector of the unique types, sorted alphanumerically.
The number of signatures for each unique type.
A vector or matrix giving the first and last locations of the
signatures of each type, after being sorted by type and
id.
A matrix of partitioned signatures ready for analysis,
sorted by type and id, in column-major format.
A matrix to pre-multiply diet estimates associated with a partitioned library to pool estimates back to the original prey types.
A matrix to post-multiply diet estimates associated with a partitioned library to pool estimates back to the original prey types.
An integer error code (0 if no error is detected).
A string contains a brief summary of the execution.
The function make_prey_part partitions a matrix of prey signatures
and into a larger number of prey types based on user input (in the vector
n_clust) informed by the results of a preceding call to the clustering
function dimac.  The signatures in sig are presumed to be
ready for analysis, which is best accomplished by a call to the function
prep_sig.
For each prey type, the column in clust designated by the
corresponding integer in n_clust is accessed and used to partition the
prey type.  For example, if the element of n_clust is 1, the first
column of clust is accessed and the prey type is not partitioned.  If
the element of n_clust is 3, the third column of clust is
accessed and the prey type is partitioned into three clusters.
The length of the integer vector n_clust must equal the number of
unique types in type.  The integers themselves should be between 1 and
the number of signatures of each type.
After all prey types have been partitioned, the prey signatures are sorted by
type and id.  The matrix rep_grp is created to map the
new prey types to the original prey types.  Multiplying diet estimates
corresponding to a partitioned prey library sig_part by rep_grp
pools the diet estimates into the original prey types.
Please refer to the vignette and documentation for the functions
dimac and prep_sig for additional
information.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | make_prey_part(sig = matrix(c(0.01, 0.20, 0.30, 0.49,
                              0.05, 0.14, 0.39, 0.42,
                              0.07, 0.21, 0.28, 0.44,
                              0.04, 0.19, 0.34, 0.43,
                              0.12, 0.29, 0.39, 0.20,
                              0.15, 0.28, 0.34, 0.23,
                              0.17, 0.21, 0.31, 0.31,
                              0.18, 0.22, 0.28, 0.32), ncol = 8),
               data.frame(type = c("prey_1", "prey_1", "prey_1", "prey_2",
                                   "prey_2", "prey_2", "prey_2", "prey_2"),
                          id = c("1-1", "1-2", "1-3", "2-1",
                                 "2-2", "2-3", "2-4", "2-5"),
                          clust_1 = c(1, 1, 1, 1, 1, 1, 1, 1),
                          clust_2 = c(1, 2, 1, 2, 1, 1, 2, 2),
                          clust_3 = c(1, 2, 3, 3, 1, 2, 3, 3),
                          clust_4 = c(0, 0, 0, 4, 1, 2, 3, 4)),
               n_clust = c(1, 2))
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.