Problem with font size in a tree
1
0
Entering edit mode
4.7 years ago
luzglongoria ▴ 50

Hi,

I am trying to make an interaction between two phylogenetic trees. I am able to run all the code (no errors) the problem is that the size of the letter of one of the trees is too big enter image description here

I have been able to change the size by plotting the plot and asking R to minimize the size but the problem is that I want to use the tree for an interaction with another tree. Please, see below:

# Packages
  library(Matrix)
  library(lme4) 
  library(ape)
  library(maps)
  library(phytools)

 #Import trees
bTreeH = read.newick(file="Huanuco_bird_tree.newick")
pTreeH = read.nexus(file="Huanuco_parasite_tree.nex")

# Prepare parasite Tree
  pTreeH = force.ultrametric(pTreeH)

# Create two fata frames

df.bird.H = data.frame(name = c("Amazilia_chionogaster",
                                "Carduelis_magellanica",
                                "Colibri_coruscans",
                                "Sayornis_nigricans",
                                "Sayornis_nigricans",
                                "Serpophaga_cinerea",
                                "Serpophaga_cinerea",
                                "Thraupis_episcopus",
                                "Zonotrichia_capensis",
                                "Zonotrichia_capensis",
                                "Zonotrichia_capensis",
                                "Zonotrichia_capensis"))                      

  df.parasite.H = data.frame(Name = c("P_SGS1",
                                    "H_PYERY01",
                                    "P_SGS1",
                                    "P_SGS1",
                                    "P_PHPAT01_",
                                    "P_SGS1",
                                    "H_SERCIN01",
                                    "H_STTA17H",
                                    "P_BAEBIC02_",
                                    "H_CHLOP01_",
                                    "P_SGS1",
                                    "H_ZOCAP01"))

# Creation of the association matrix:
  associationH <- cbind(df.bird.H, df.parasite.H)

# Create a vector for colors
  cols.H <- c('2','1','2','2','1','2','1','1','1','1','2','1')

# Create a vector for chose colors
  cols.1.H <- c("#e7298a","grey","#e7298a","#e7298a","grey","#e7298a","grey","grey","grey","grey","#e7298a","grey")  #1

# Create the two trees face to face
  Interaction_Huanuco <- cophyloplot(bTreeH, pTreeH, assoc=associationH,
                   length.line = 4, space = 100, gap = 3, col = cols.1.H)

There is no error message but the bTreeH (the one with more names) is imposible to read properly because of the size of the letters. Some months ago I was able to run these analyses with any trouble, the size of the letters seemed to adjust itself but now... I am running exactly the same code and I have this problem.

Any help is more than welcome.

tree interaction fontsize cophyloplot • 3.8k views
ADD COMMENT
2
Entering edit mode
4.5 years ago
tiffany.chin ▴ 20

I had the same problem; see: https://www.mail-archive.com/r-sig-phylo@r-project.org/msg02317.html

I wasn't able to copy the internal function as mentioned in the above link, but I found a work around.

You'll have to edit the internal function plotCophylo2 to change the text size with cex: https://rdrr.io/cran/ape/src/R/cophyloplot.R (where the function refers to text, cex = 1; change to cex = 0.5).

In my case, I just called the internal function a different name, changed the code for text size, and then fix(cophyloplot) to recall the new internal function. After that, it ran smoothly.

Hope that helps.

ADD COMMENT

Login before adding your answer.

Traffic: 2685 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6