I have multiple data frames in the following format:
Dataframe:1
Var1 Var2 cor p fdr
Bacteroides_galacturonicus Lactobacillus_rogosae 0.967374392060265 0 0
Bacteroides_galacturonicus Lachnospira_pectinoschiza 0.526779994497013 0 0
Lactobacillus_rogosae Lachnospira_pectinoschiza 0.29419393866076 0 0
Bacteroides_galacturonicus Bacteroides_salyersiae 0.374581964109831 0.548 0.829267117726658
Lactobacillus_rogosae Bacteroides_salyersiae 0.45736458243079 0.002 0.03622024291498
Lachnospira_pectinoschiza Bacteroides_salyersiae 0.566636776534 0.21 0.56910941475827
Bacteroides_galacturonicus Holdemanella_biformis 0.342443352 0.094 0.394447279549719
Lactobacillus_rogosae Holdemanella_biformis 0.15592768883205 0.174 0.527328455284553
Dataframe:2
Var1 Var2 cor p fdr
Lactobacillus_rogosae Bacteroides_galacturonicus 0.467374392060265 0 0
Lachnospira_pectinoschiza Bacteroides_galacturonicus 0.426779994497013 0 0
Lachnospira_pectinoschiza Lactobacillus_rogosae 0.69419393866076 0 0
Bacteroides_galacturonicus Bacteroides_salyersiae 0.074581964109831 0.548 0.829267117726658
Lactobacillus_rogosae Bacteroides_salyersiae 0.320636458243079 0.002 0.03622024291498
Lachnospira_pectinoschiza Bacteroides_salyersiae 0.132857736776534 0.21 0.56910941475827
Bacteroides_galacturonicus Holdemanella_biformis 0.19490130543352 0.094 0.394447279549719
Lactobacillus_rogosae Holdemanella_biformis 0.14472768883205 0.174 0.527328455284553
These are two correlation matrices which I want to bind through rowbind()
. But the problem is same correlation is represented in two different ways in two dataframes. For a pair of correlation, a bacteria is found in Var1
in Dataframe:1 while the for the same pair of correlation, the same bacteria is represented in Var2
in Dataframe:2 ( see first correlation ). I want to make a column so that each pair of correlation can be represented in same format. e.g.:
Var1:Var2 cor p fdr
Lactobacillus_rogosae:Bacteroides_galacturonicus 0.967374392060265 0 0
Lactobacillus_rogosae:Bacteroides_galacturonicus 0.467374392060265 0 0
can anyone please help me achieveing this?
many many thanks