Description Usage Arguments Value See Also Examples
View source: R/representative.R
Computes representative point based on the coordinates of points which are in the same group.
1 2 |
input |
A matrix which contains the coordinates of samples. Usually this is the
result of ordination of normalized RADs using multi-dimensional scaling ( |
ids |
Vector of row numbers of the desired group, from which a representative point is going to be represented |
coord_names |
A vector which contains the coordintes number that should be used to create representative point.
Default is |
standard_error_mean |
A logical. If |
plot |
A logical. If |
... |
other graphical parameters to use for plotting. This function uses
internally the functions |
A list of following parameters:
$mean: Contains the average of points. A vector with the length of coordinates
used for computing the average. These coordinates are preset in coord_names
.
$sd: A vector with a length similar to mean
which contains the
standard deviation for each coordinate.
$mean_standard_error: A vector with a length similar to mean
which
contain the standard deviation of the mean for each coordinate. This vector is the result of sd / sqrt(n)
,
when n is the number of members of the group (length of sample_ids
).
If plot = TRUE
, representative points would be added to the previous plot.
If standard_error_mean = TRUE
, the standard error of the mean would be added to the representative points.
RADnormalization
for normalize an abundance vector. This function return more details compared to RADnormalization_matrix
,
RADnormalization_matrix
for normalize an entire otutable,
representative_RAD
for study the representative of group of norm rads.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | line_cols <- c("green","red","blue")
sample_classes <- c(1,1,1,1,2,2,3,3,1,1,2,3,3,1,1,2,3,3)
maxrank <- 400
data("gut_nrads")
nrads <- gut_nrads
nrads <- nrads$norm_matrix
#distance matrix using manhattan distance
d <- dist(x = nrads,method = "manhattan")
#ordination using classical multi-dimensional scaling
mds <- cmdscale(d = d,k = 5,eig = TRUE)
#plot the points
plot(mds$points,xlab = "First coordinate",ylab = "Second coordinate",pch = 19,cex =1,
col = line_cols[sample_classes],
main = "MDS plot with representative points \n of each group and error bars")
#add the representative points wit erorr bar to the previous plot
a <- representative_point(input = mds$points,ids = which(sample_classes == 1),
col = scales::alpha(line_cols[1],0.5),
plot = TRUE,standard_error_mean = TRUE,pch = 19, cex = 4)
a <- representative_point(input = mds$points,ids = which(sample_classes == 2),
col = scales::alpha(line_cols[2],0.5),
plot = TRUE,standard_error_mean = TRUE,pch = 19, cex = 4)
a <- representative_point(input = mds$points,ids = which(sample_classes == 3),
col = scales::alpha(line_cols[3],0.5),
plot = TRUE,standard_error_mean = TRUE,pch = 19, cex = 4)
legend("bottomleft",bty = "n",legend = c("pre Cp","under Cp","post Cp"),
col = line_cols,pch = 19)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.