Skip to content

Commit

Permalink
phylofactorization updates
Browse files Browse the repository at this point in the history
  • Loading branch information
reptalex committed Jul 7, 2018
1 parent aef707a commit 3ab245e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion R/PhyloFactor.R
Expand Up @@ -339,7 +339,7 @@ PhyloFactor <- function(Data,tree,X=NULL,frmla = Data~X,choice='var',transform.f
}
tree <- ape::drop.tip(tree,setdiff(tree$tip.label,rownames(Data)))}
if (!all(rownames(Data)==tree$tip.label)){
warning('rows of data are in different order of tree tip-labels - use output$data for downstream analysis, or set Data <- Data[tree$tip.label,]')
warning('rows of data are in different order of tree tip-labels - use output$data for downstream analysis, or set Data <- Data[output$tree$tip.label,]')
Data <- Data[tree$tip.label,]
}

Expand Down
12 changes: 5 additions & 7 deletions R/pf.heatmap.R
Expand Up @@ -58,18 +58,16 @@ pf.heatmap <- function(PF=NULL,tree=NULL,Data=NULL,factors=NULL,column.order=NUL

if (!is.null(Data)){
if (nrow(Data) != length(PF$tree$tip.label)){
stop('number of rows of Data does not equal number of columns in PF$tree tip-labels')
stop('number of rows of Data does not equal number of tips in PF$tree')
} else {
if (is.null(rownames(Data))){
warning('No rownames of input Data - pf.heatmap will assume rows are in same order of tree tip labels')
rownames(Data) <- PF$tree$tip.label
} else {
if (!all.equal(rownames(Data),PF$tree$tip.label)){
if (!all.equal(sort(rownames(Data)),sort(PF$tree$tip.label))){
warning('Rownames of Data cannot be matched with PF$tree tip-labels. Assuming rows are in same order as tree tip-labels')
rownames(Data) <- PF$tree$tip.label
} else {
if (!all(rownames(Data) %in% PF$tree$tip.label & all(PF$tree$tip.label %in% rownames(Data)))){
stop('could not match all rownames of Data with all tree tip labels.')
} else {
Data <- Data[PF$tree$tip.label,]
}
}
}
}
Expand Down

0 comments on commit 3ab245e

Please sign in to comment.