Skip to content

convert output matrix to triangular format in R #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
TonyMane opened this issue Mar 26, 2022 · 1 comment
Open

convert output matrix to triangular format in R #26

TonyMane opened this issue Mar 26, 2022 · 1 comment

Comments

@TonyMane
Copy link

greetings, i enjoy using simka but i have a question regarding manipulating the output files.
specifically, is there a way to convert the 'mat_abundance_braycurtis.csv' into a triangular lower matrix.
i'm really interested in working with a triangular matrix, much the same as that produced by vegan.
for example:

library(vegan)
mat <- matrix(1:9, 3, 3)
mat.dis<-vegdist(mat)
mat.dis
           1          2
2 0.11111111           
3 0.20000000 0.09090909
@clemaitre
Copy link
Collaborator

Hi,
thanks for using simka !
Here is a way in R to transform a square matrix into a triangular one:

mat=as.matrix(read.table("mat_abundance_braycurtis.csv",sep=";", header=TRUE, row.names=1))
mat[upper.tri(mat)]=0

I hope it helps,
Best,
Claire

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants