convert_to_long: Converts wide format ILR transformed data to long format

Description Usage Arguments Value Examples

View source: R/general_utils.R

Description

Converts wide format ILR transformed data (see philr) to long format useful in various plotting functions where long format data is required.

Usage

1

Arguments

df

PhILR transformed data in wide format (samples by balances) (see philr)

labels

vector (of length nrow(df)) with labels to group samples by

Value

df in long format with columns

Examples

1
2
3
4
5
6
7
tr <- named_rtree(5)
df <- t(rmultinom(10,100,c(.1,.6,.2,.3,.2))) + 0.65   # add a small pseudocount
colnames(df) <- tr$tip.label

df.philr <- philr(df, tr, part.weights='enorm.x.gm.counts',
      ilr.weights='blw.sqrt', return.all=FALSE)
convert_to_long(df.philr, rep(c('a','b'), 5))

Example output

Registered S3 method overwritten by 'treeio':
  method     from
  root.phylo ape 
Building Sequential Binary Partition from Tree...
Building Contrast Matrix...
Transforming the Data...
Calculating ILR Weights...
   sample labels coord       value
1       1      a    n1 -0.58270059
2       2      b    n1 -0.03514878
3       3      a    n1 -0.03590293
4       4      b    n1  0.06702808
5       5      a    n1 -0.15487250
6       6      b    n1  0.90362914
7       7      a    n1 -0.32638808
8       8      b    n1 -0.10663525
9       9      a    n1  0.42003051
10     10      b    n1 -0.03246717
11      1      a    n2 -0.56697063
12      2      b    n2 -0.45560642
13      3      a    n2  0.62322191
14      4      b    n2  0.65184003
15      5      a    n2 -0.11803164
16      6      b    n2  0.11514588
17      7      a    n2  0.15975701
18      8      b    n2  0.09883433
19      9      a    n2 -0.59694233
20     10      b    n2 -0.17206504
21      1      a    n3 -0.25720195
22      2      b    n3  0.33094315
23      3      a    n3  0.21636836
24      4      b    n3 -0.09205965
25      5      a    n3 -0.92521870
26      6      b    n3  0.29138421
27      7      a    n3  0.40398077
28      8      b    n3  1.37841987
29      9      a    n3 -0.90824141
30     10      b    n3 -0.15419198
31      1      a    n4 -0.17502213
32      2      b    n4 -0.43002874
33      3      a    n4  0.31789500
34      4      b    n4  0.52860718
35      5      a    n4  0.52821178
36      6      b    n4  0.06341789
37      7      a    n4 -0.49538939
38      8      b    n4 -1.39536693
39      9      a    n4  0.06272743
40     10      b    n4  0.52842995

philr documentation built on Nov. 8, 2020, 5:38 p.m.