Re: [R-sig-phylo] Changing the color of text and nodes in arc.cladelabels in phytools

2021-04-08 Thread Russell Engelman
Dear Dr. Revell,

I tried par(fg="green") and it kind of worked. It changed the curved
labels and their associated text to a color, but it only changed the
outline of the dots denoting marked nodes. Additionally, if I tried to
input a vector of colors equal to my number of groups (e.g.,
par(fg=c("red","green","blue","cyan","orange")), I get the error ""fg1" is
not a graphical parameter".

The same results are produced if I try par(col="green"). The command
par(col.lab="green") just turns the entire background of the figure green.
I also tried part(fill="green"), but got the warning message "In par(fill =
"green") : "fill" is not a graphical parameter". The command
par(bg="green') does nothing.

Sincerely,
Russell

On Mon, Apr 5, 2021 at 11:11 AM Liam J. Revell  wrote:

> Dear Russell.
>
> I'm sorry that arc.cladelabels does not have the functionality that you
> want.
>
> Have you tried setting par(fg)? E.g.:
>
> par(fg="the color you want")
> arc.cladelabels(...)
> par(fg="black")
>
> You could also try par(col) or par(col.lab).
>
> Let me know if that works, if not I can see about adding the option you
> need to the function.
>
> All the best, Liam
>
> Liam J. Revell
> University of Massachusetts Boston [Assoc. Prof.]
> Universidad Católica de la Ssma Concepción [Adj. Res.]
>
> Web & phytools:
> http://faculty.umb.edu/liam.revell/, http://www.phytools.org,
> http://blog.phytools.org
>
> Academic Director UMass Boston Chile Abroad:
> https://www.umb.edu/academics/caps/international/biology_chile
>
> U.S. COVID-19 explorer web application:
> https://covid19-explorer.org/
>
> On 4/4/2021 10:36 PM, Russell Engelman wrote:
> > EXTERNAL SENDER
> >
> > Dear R-sig-phylo,
> >
> > I am a researcher who has been trying to plot a continuous trait map
> onto a
> > phylogeny using the phytools and ape packages in R. I have been trying to
> > denote specific clades using the arc.cladelabels function in phytools,
> but
> > I have also been trying to color-code the text, curve, and node for each
> of
> > the groups to make it easier to see which branches pertain to which
> clade.
> > However, I have been having a lot of trouble adjusting the properties of
> > the text and nodes created by arc.cladetools.
> >
> > Here is an example using the *Anolis *svl data that shows what I mean:
> >
> > ```
> > library(ape)
> > library(phytools)
> > anole.tree<-read.tree("
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2Feqg2015%2Fdata%2Fanole.tredata=04%7C01%7Cliam.revell%40umb.edu%7C017b93bf1ab74239149608d8f84157ed%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637532306822786314%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=NN6WMsldnLYZtuXWpndNA6ORhejdZbJdqDuNeI6PsY8%3Dreserved=0
> ")
> > svl <- read.csv("
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2Feqg2015%2Fdata%2Fsvl.csvdata=04%7C01%7Cliam.revell%40umb.edu%7C017b93bf1ab74239149608d8f84157ed%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637532306822796308%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=EA2P63ohsozCGtfU9hpg9k319zu168X%2BfmCZlOJ4cX4%3Dreserved=0
> ",
> >  row.names=1)
> > svl <- as.matrix(svl)[,1]
> > fit <- fastAnc(anole.tree,svl,vars=TRUE,CI=TRUE)
> > obj<-contMap(anole.tree,svl,plot=FALSE)
> > nodes<-c(mrca(anole.tree)["equestris","noblei"],
> >   mrca(anole.tree)["barahonae","barbatus"])
> > labels<-c("clade1","clade2")
> > plot(obj,type="fan",cex=5,fsize=0.5,lwd=5)
> > for(i in 1:length(nodes))
> >arc.cladelabels(text = labels[i],node = nodes[i],mark.node = TRUE,
> > ln.offset =
> >  1.39, col = c("green","red")[i], lab.offset =
> >  1.46, fsize = .5, orientation = "curved")
> > ```
> >
> > None of the calls I have tried for the arc.cladelabels function seem to
> be
> > able to adjust the color of the text labels the function creates (e.g.,
> > text.col, col.text, col.lab, etc), nor the color or size of the nodes
> when
> > mark.node = TRUE. The "col" call only affects the line drawn. Examining
> the
> > base code for arc.cladelabels finds that the color of the nodes is always
> > set to be red, and I have been unable to figure out how to alter it. I
> > could always write a custom function that copies arc.cladelabels but
> alters
> > the color function, but my concern is that this is part of an RMarkdown
> > document and as a result any alteration I make to the arc.cladelabels
> > function will not show up when another person knits the data (as it will
> > call on their copy of phytools).
> >
> > Alternatively I am wondering if it is possible to export the tree to
> ggtree
> > and add the nodes there, but I have noticed that ggtree does not allow
> for
> > arced clade labels and for some reason it also greatly extends the
> margins
> > of the plot beyond the margins of the graph when its equivalent of
> > 

Re: [R-sig-phylo] Changing the color of text and nodes in arc.cladelabels in phytools

2021-04-05 Thread Liam J. Revell



Dear Russell.

I'm sorry that arc.cladelabels does not have the functionality that you 
want.


Have you tried setting par(fg)? E.g.:

par(fg="the color you want")
arc.cladelabels(...)
par(fg="black")

You could also try par(col) or par(col.lab).

Let me know if that works, if not I can see about adding the option you 
need to the function.


All the best, Liam

Liam J. Revell
University of Massachusetts Boston [Assoc. Prof.]
Universidad Católica de la Ssma Concepción [Adj. Res.]

Web & phytools:
http://faculty.umb.edu/liam.revell/, http://www.phytools.org, 
http://blog.phytools.org


Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile

U.S. COVID-19 explorer web application:
https://covid19-explorer.org/

On 4/4/2021 10:36 PM, Russell Engelman wrote:

EXTERNAL SENDER

Dear R-sig-phylo,

I am a researcher who has been trying to plot a continuous trait map onto a
phylogeny using the phytools and ape packages in R. I have been trying to
denote specific clades using the arc.cladelabels function in phytools, but
I have also been trying to color-code the text, curve, and node for each of
the groups to make it easier to see which branches pertain to which clade.
However, I have been having a lot of trouble adjusting the properties of
the text and nodes created by arc.cladetools.

Here is an example using the *Anolis *svl data that shows what I mean:

```
library(ape)
library(phytools)
anole.tree<-read.tree("https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2Feqg2015%2Fdata%2Fanole.tredata=04%7C01%7Cliam.revell%40umb.edu%7C017b93bf1ab74239149608d8f84157ed%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637532306822786314%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=NN6WMsldnLYZtuXWpndNA6ORhejdZbJdqDuNeI6PsY8%3Dreserved=0;)
svl <- 
read.csv("https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2Feqg2015%2Fdata%2Fsvl.csvdata=04%7C01%7Cliam.revell%40umb.edu%7C017b93bf1ab74239149608d8f84157ed%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637532306822796308%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=EA2P63ohsozCGtfU9hpg9k319zu168X%2BfmCZlOJ4cX4%3Dreserved=0;,
 row.names=1)
svl <- as.matrix(svl)[,1]
fit <- fastAnc(anole.tree,svl,vars=TRUE,CI=TRUE)
obj<-contMap(anole.tree,svl,plot=FALSE)
nodes<-c(mrca(anole.tree)["equestris","noblei"],
  mrca(anole.tree)["barahonae","barbatus"])
labels<-c("clade1","clade2")
plot(obj,type="fan",cex=5,fsize=0.5,lwd=5)
for(i in 1:length(nodes))
   arc.cladelabels(text = labels[i],node = nodes[i],mark.node = TRUE,
ln.offset =
 1.39, col = c("green","red")[i], lab.offset =
 1.46, fsize = .5, orientation = "curved")
```

None of the calls I have tried for the arc.cladelabels function seem to be
able to adjust the color of the text labels the function creates (e.g.,
text.col, col.text, col.lab, etc), nor the color or size of the nodes when
mark.node = TRUE. The "col" call only affects the line drawn. Examining the
base code for arc.cladelabels finds that the color of the nodes is always
set to be red, and I have been unable to figure out how to alter it. I
could always write a custom function that copies arc.cladelabels but alters
the color function, but my concern is that this is part of an RMarkdown
document and as a result any alteration I make to the arc.cladelabels
function will not show up when another person knits the data (as it will
call on their copy of phytools).

Alternatively I am wondering if it is possible to export the tree to ggtree
and add the nodes there, but I have noticed that ggtree does not allow for
arced clade labels and for some reason it also greatly extends the margins
of the plot beyond the margins of the graph when its equivalent of
arc.cladelabels (geom_cladelabel) is called.

I was wondering if anyone else here knew any potential ways I could adjust
the color and size of the text and nodes for this function.

Sincerely,
Russell

 [[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylodata=04%7C01%7Cliam.revell%40umb.edu%7C017b93bf1ab74239149608d8f84157ed%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637532306822796308%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=Zwv%2BMozIB7k%2BouxvRxE7VDq9KetciJh2E3ZO5Iung0g%3Dreserved=0
Searchable archive at