Skip to content

Commit

Permalink
update the dist calculation in loadings of PCA in trans_beta
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiLiubio committed Aug 11, 2024
1 parent 32176d2 commit b5ceba7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/trans_beta.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ trans_beta <- R6Class(classname = "trans_beta",
loading <- model@loadingMN[, 1:ncomp]
}
loading %<>% as.data.frame
loading[, "dist"] <- loading[, plot.x]^2 + loading[, plot.y]^2
loading <- loading[order(loading[, "dist"], decreasing = TRUE), ]
if(scale_species){
maxx <- max(abs(scores_sites[, plot.x]))/max(abs(loading[, plot.x]))
loading[, plot.x] %<>% {. * maxx * scale_species_ratio}
maxy <- max(abs(scores_sites[, plot.y]))/max(abs(loading[, plot.y]))
loading[, plot.y] %<>% {. * maxy * scale_species_ratio}
}
loading[, "dist"] <- loading[, plot.x]^2 + loading[, plot.y]^2
loading <- loading[order(loading[, "dist"], decreasing = TRUE), ]
outlist <- list(model = model, scores = combined, loading = loading, eig = expla)
}
if(method %in% c("PCoA", "NMDS")){
Expand Down

0 comments on commit b5ceba7

Please sign in to comment.