Momocs default PCA remove coloured boxes behind points - r

A R / Momocs learner here.
Currently I'm creating a PCA with some leaf shapes (20+ different populations).
I have created the harmonics and now applying the default (?) PCA graphic:
lo.f <- efourier(lo, 12)e
lo.p <- PCA(lo.f, fac=pop)
plot(lo.p, ~pop)
This produces the default PCA graphic (dots with coloured boxes behind), but the code itself for the graphic is hidden.
I'd like to remove the coloured boxes behind each population (and replace them with something else). It's just too busy with 20+ boxes.
Is it possible to know please where to view the code for the default PCA and remove the coloured boxes bounding each population?
Thanks and apologies such a basic question I am a learner.
M

Thanks all, a Momocs authors got back to me.
Basically the answer was instead of using the standard PCA command (listed above in the question) you can apply instead another command- plot_PCA(lo.p, ~pop, chull=FALSE)
The useful part in my situation being chull=FALSE part, which removed the background shading. There are a number of other options the author advised me to assit in "tweaking' the graphics which I'm currently playing around with.
Thanks all
Michael

Related

Forest plot (metafor) with 90 effect sizes: how to make text readable and adjust row spacing

I am working on a forest plot with the metafor package. With the help of (http://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups) and several forum entries I wrote a code but unfortunately the letters are blurry. I tried making the plot bigger with windows () which did help a bit but still it is not ready for putting in a paper.
It looked like this:also blurry with zooming in
When I used only a subset of effect sizes for the subgroup analysis the forest plot the text was better readable but only until about 15 effect sizes). And because the row spacing is so narrow I can´t even think about putting summary polygons for subgroups in between.
This was the code I used for my data (90 effect sizes in multilevel model):
forest(Model1,
slab= data$Author, #labeled by author
# cex=0.75, #only made the text bigger but did not change the row distance, so the text overlapped
ylim=c(-1, 100),
header="Author(s) and Year")
There were a lot of extra arguments in examples of forest plots I saw online but I am not sure of their meaning in forest plot.
Does someone know how to solve this spacing problem or what arguments I need to add to the code e.g. to broaden the space between the rows? Is there a “guide” for working with forest?
Thank you very much in advance!
Blurriness has nothing to do with the forest() function - it's a matter of how you are saving the plot. You should use functions like png() with a high enough resolution. Or use pdf() where you can zoom in to your heart's content without ever seeing any blurriness.
As for a "guide", I would suggest reading the documentation first:
https://wviechtb.github.io/metafor/reference/forest.rma.html
https://wviechtb.github.io/metafor/reference/forest.default.html
Then you will start to understand what the arguments do.

Removing grid lines in a map and smoothing in maps

I am trying to remove the grids on my map. I used several commands for example: plt.grid(), plt.rcParams["axes.grid"] = False but nothing happens, the map produced as is with the grids. Is there any possible way to remove the grids?
Another thing also, how can I make my plot to be smoothed instead of having the data as blocks (see below a sample of the plot).
enter image description here
Please assist in this regard.
Truly appreciate your time.
Thank you.

Link tip labels to phylogenetic tree using dots and fix overcrowded tip labels

I'm attempting to produce an ancestral reconstruction using the ape and phytools package in Rstudio. My problem is that in my phylogenetic tree the tip labels / species names are overcrowded and illegible. Currently, my tree has a dataset of 262 species.
An example nexus file of the data can be found here.
The Ancestral reconstruction tree I have produced so far is here: http://i.imgur.com/WFoEu7S.png.
Each species has a character state of 0 or 1 and has node and tip labels addressing each state. Eventually i'd like to color the branches with their respective character state(which I have as either red or black.)
Ideally, I wish to produce a non-ultrametric tree similar to a previous question on stack overflow in this link here.
I've tried implementing the R code from this link for my own tree with little success.
Below is my code in R. I am still learning R and am unfamiliar with certain plotting methods and suspect that may be the issue here:
tree = read.nexus("test_nexus")
dichot_tree = multi2di(tree)
dichot_tree$edge.length<-runif(n=nrow(dichot_tree$edge),min=0,max=1)
dichot_tree$edge.length[dichot_tree$edge.length<1]<-1
domest = read.nexus.data("test_nexus")
aceDISCRETE<-ace(as.numeric(domest), dichot_tree, type="discrete")
plot(dichot_tree, cex=0.5, label.offset=1, no.margin=TRUE)
tiplabels(pch=22, bg=as.numeric(domest),cex=1, adj=1)
nodelabels(pie=aceDISCRETE$lik.anc, piecol=c("black", "red"), cex=0.25)
There are a couple possible ways to make the tip labels more readable.
First, you could decrease the font size (that would be the cex parameter of the plot function).
Second, you are using RStudio, and it looks like you currently have your plot area as a square.
You can adjust the different panels to make the plot area a very tall rectangle, which would extend your tree when you plot it.
Alternatively, you could create an external plot area (I use windows() and you can specify height and width.)
Alternatively, when saving a plot in RStudio, you should be able to change the output height/width/aspect ratio. You should be able to make it much taller here as well.

Shaded graph/network plot?

I am trying to plot quite large and dense networks (dput here). All I end up with is a bunch of overlapping dots, which does not really give me a sense of the structure or density of the network:
library(sna)
plot(data, mode = "fruchtermanreingold")
However, I have seen plots which utilizes fading to visualize the degree to which points overlap, e.g.:
How can I implement this "fading" in a plot of a graph?
Here's one way:
library(sna)
library(network)
source("modifieddatafromgist.R")
plot.network(data,
vertex.col="#FF000020",
vertex.border="#FF000020",
edge.col="#FFFFFF")
First, I added a data <- to the gist so it could be sourced.
Second, you need to ensure the proper library calls so the object classes are assigned correctly and the proper plot function will be used.
Third, you should use the extra parameters for the fruchtermanreingold layout (which is the default one for plot.network) to expand the area and increase the # of iterations.
Fourth, you should do a set.seed before the plot so folks can reproduce the output example.
Fifth, I deliberately removed cruft so you can see the point overlap, but you can change the alpha for both edges & vertices (and you should change the edge width, too) to get the result you want.
There's a ton of help in ?plot.network to assist you in configuring these options.

plot igraph in a big area

Just wondering if it is possible to increase the size of the plot so that the nodes and edges can be more scattered over the plot.
Original plot:
What are expected:
I tried many parameters in the layout function such as area, niter, and so on, but all of them do not work. By the way, I am using 'igraph' package in R.
If you are referring to the actual size of the produced output (pdf, png, etc), you can configure it with the width and height parameters. Check this link for png,bpm, etc, and this link for PDF format.
A MWE is something like this:
png("mygraph.png", heigh=400, width=600)
#functions to plot your graph
dev.off()
If you are referring to the size of the graphic produced by the layout function, as #MrFlick referred, you should check the parameters of the particular layout you are using.
Hope it helps you.
In your second graph, it's obviously the graph can be divided into several clusters (or sections). If I understood you correctly, you want to have a layout that separates your clusters more visibly.
Then you can draw this by calculating a two-level layout:
First, calculate the layout of the graph in order to find a place for each cluster.
Second, calculate the layout in each cluster according to first step and plot nodes in the corresponding place.

Resources