StevenVB12 / patternize

An R package for quantifying color pattern variation
31 stars 8 forks source link

Question regarding patPCA output #11

Closed RomanB22 closed 5 years ago

RomanB22 commented 6 years ago

Hello Steven, nice package! Thank you very much. Sorry to bother you, but I didn't understand which are the outputs of the patPCA function. I could make the PCAs plot, but I cannot get the coordinates of the points plotted in the PCA. There is a way in which I can obtain them? I have looked into the code but I didn't recognize where the information about the PCAs values are. Sorry but I'm new in R, so it's difficult for me to understand all the package functions.

Best regards,

Román

StevenVB12 commented 6 years ago

Hi Román,

the output of the PCA analysis with the prcomp coordinates can be found in pcaOut if you ran pcaOut <- patPCA().

Depending on how you ran the analysis you might have to access it as pcaOut[3].

' @return If plot = TRUE: List including a [1] dataframe of the binary raster values that can be used for

' principle component analysis, [2] a dataframe of sample IDs and specified population

' colors and [3] prcomp results. If plot = FALSE: prcomp result.

Hope this helps. Let me know if you have any other questions.

Best, Steven

RomanB22 commented 5 years ago

Hi Steven,

I have a question: How can I have an idea of which characteristics are taken into account on each PCA? Can I reconstruct the image of each component from the pcaOut[3]?

Sorry but I'm new in the image processing area.

Best regards, Román

StevenVB12 commented 5 years ago

Hi Roman,

when you set 'plotChanges = TRUE' in patPCA(), the function should plot a prediction of what the image looks like at the minimum and maximum end of that PC axis (while keeping the values for other PC axis at 0). In that we you can visualize the characteristics along that axis.

Does that help? I can also provide you raw code for the transformations if there is other things you would like to achieve.

Steven

RomanB22 commented 5 years ago

Hi Steven, it helps a lot, but I would be glad if you could give an exampl of the trasnformations needed in order to go from pcaOut[3] to an image similar to the output of 'plotChanges = TRUE', but with another combination of PCAs?

Thank you

StevenVB12 commented 5 years ago

Hi Roman,

one way is to specify other PCx and PCy to whatever PC axis you want to look at.

I also pushed a function (createPhenotype) to the github repository that allows to recreate a phenotype for a specified combination of PCA values. This is also what the patPCA function uses for plotting and takes pcaOut[[3]] as input. The code is short and you can have a look at it here: https://github.com/StevenVB12/patternize/blob/master/R/createPhenotype.R. It takes a few arguments that you best set the same as for patPCA.

Hope this helps.

Steven

RomanB22 commented 5 years ago

Thank you very much Steven! I could use the patPCA and also the createPhenotype functions :)

I will mark this topic as closed.

Best,

Román

StevenVB12 commented 5 years ago

Great! I look forward seeing any potential output.

Steven