| calc_all_lscps {Morphoscape} | R Documentation |
Calculate adaptive landscapes for a matrix of weights
Description
calc_all_lscps() calculates adaptive landscapes from a set of kriged surfaces of functional characteristics and sets of weights for those characteristics.
Usage
calc_all_lscps(kr_data, grid_weights, file = NULL)
Arguments
kr_data |
a |
grid_weights |
a |
file |
the path of a file to save the resulting output object, which may be quite large. The file path should contain an .rds or .rdata extension, which will be saved using |
Details
calc_all_lscps() computes a combined adaptive landscape for each of the supplied sets of weights. The optimal landscape overall or for certain subsets of the sample data can be found using calcGrpWprime or calcWprimeBy. calc_lscp can be used to extract the surface of the weighted functional characteristics for each set of weights (see Examples).
Because the resulting objects are so large, it can be a good idea to save them after creation, which can be done automatically using the file argument. If the supplied file extension is .rds, saveRDS will be used to save the object to the supplied file path, and the file can be loaded using readRDS. If the supplied file extension is .RData, save will be used to save the object to the supplied file path, and the file can be loaded using load.
Value
An all_lscps object containing the following components:
dataframe |
a list of the |
wtd_lscps |
a list containing the weightred fitness values for each set of weights for the |
grid_weights |
the |
See Also
calc_lscp for computing a single weighted landscape or extracting the weighted surface of functional characteristics for a single set of weights.
generate_weights for generating the required matrix of weights.
calcGrpWprime and calcWprimeBy for finding optimal sets of weights and adaptive landscapes for subgroups.
Examples
data("warps")
data("turtles")
warps_fnc <- as_fnc_df(warps,
func.names = c("hydro", "fea"))
kr_surf <- krige_surf(warps_fnc, new_data = turtles)
grid_weights <- generate_weights(n = 20, data = kr_surf)
all_lscps <- calc_all_lscps(kr_surf,
grid_weights = grid_weights)
all_lscps
# Extract the weighted surface for a single set
# of weights (here, the 6th set of weights)
grid_weights[6,]
wtd_lscp_6 <- calc_lscp(all_lscps, i = 6)
wtd_lscp_6
# This aligns with the weighted fitness value:
mean(all_lscps$wtd_lscps$new_data[,6])