get_closepairs_auto | R Documentation |
This function takes a distance matrix and finds all pairs of samples that are within a distance cutoff determined by an automated algorithm that finds valleys in the histogram of the pairwise distance distribution. The pairs are returned as an nx2 matrix, where n is the number of close pairs, and the elements of the matrix are the indices of the samples in that close pair in the distance matrix. Plotting the histogram with the cutoff is optional. This function was inspired by some code from Lazarus Thurston found at: https://stackoverflow.com/questions/13133297/calculating-peaks-in-histograms-or-density-functions.
get_closepairs_auto(
distance_matrix,
which_valley,
nbins,
maxvalleyheight,
show_hist,
verbose
)
distance_matrix |
A distance matrix |
which_valley |
The ordinal valley to be used for the cutoff. |
nbins |
Number of bins for the histogram |
maxvalleyheight |
Same as minpeakheight in pracma::findpeaks, which is the function used here. Will probably be need to be adjusted iteratively by the user. |
show_hist |
Boolean indicator for whether or not to plot a histogram of the distances and cutoff. |
verbose |
TRUE to report distance cutoff, FALSE to not |
get_closepairs_auto(distance_matrix, 1, 100, T) # This will yield a cutoff for the 1st valley in the pairwise distance distribution,
# use 100 bins for the histogram, and shows the plot.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.