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

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

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

# 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 • 1.6k views
2
Entering edit mode
22 months 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.