Closed weihanlau closed 11 months ago
Hi Wei,
I made some updates recently and perhaps I broke something. Could you send me all the imputs and your code needed to reproduce your example?
With recolorize, it might also be better to first use patLan() and then the recolorize functions. I don’t think there should be a need to use patLanRGB() after that.
Hope this helps.
Steven
From: weihanlau @.> Sent: Friday, 1 September 2023 07:47 To: StevenVB12/patternize @.> Cc: Subscribed @.***> Subject: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Dear Steven,
I've been trying to use the function patLanRGB() in the patternize package to extract a colour pattern from some beetle specimens. I'm running into some problems, though. Every time I run the patLanRGB() function, I get several warning messages that reads: "Warning: [rast] unknown extent", and the resulting pattern that gets plotted looks really strange (like a bunch of dots in a neat row, which is not what I was expecting at all).
Here's are some plots that were returned from the following code. It's clearly picking up the RGB values from the light brown parts, but I don't understand why it looks like this.
patlanRGB <- patLanRGB(samplejpg, landmarkListRGB, RGB, colOffset = 0.05, transformRef = landmarkListRGB[[1]], resampleFactor = 1, adjustCoords = T, plot = "compare")
[000062]https://user-images.githubusercontent.com/116670367/264933251-3da0b243-2e19-4b7e-9ca5-12c5ea277351.png [000069]https://user-images.githubusercontent.com/116670367/264933272-262c19a0-c8ef-4efb-b19f-81e17c27a3d5.png
For reference, attached below is a picture of one of the images that I'm trying to extract the colour pattern from. I'm also not really sure why patLanRGB() spits out a "cropped" rectangular portion of each image (see above).
[CNC1151335]https://user-images.githubusercontent.com/116670367/264933414-107e4c65-d337-4c2b-b10d-f4b8a5eb351d.jpg
Would you happen to know why all of this is happening?
My pictures are all jpgs. Prior to this, I ran the images that I'm using through the package recolorize to impose a standard colour palette of two colours on to them (hence, them looking quite pixelated). The RGB values that I'm using are the RGB values from the light brown area of the specimen, which should be the same for all of the images, since I imposed a colour palette with recolorize on all of my images.
Thank you so much for any help at all!
Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC4ZRC5XQMFSZAPVPP63XYFZDTANCNFSM6AAAAAA4HBYVXU. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>
Hi Steven,
Thank you so much for your really prompt response!
Here is my code, along with the jpg. images in the folder "recolored images" that I used to read back into R as Raster objects with makeList(), and the landmarks list in the folder "RGB landmarks".
https://github.com/weihanlau/Cicindela_Pattern
To make the recolored images, I read the original images with patternize functions and ran alignLan() on them, before convertingthe rasters into arrays and running recolorize functions on them to make a universal colour palette. I then exported the recolorized objects as jpgs. and used those jpgs. in the code listed on github. Since they were already aligned, my landmarks that I used in patLanRGB() are all the same. I'm using recolorize to create simplified colour-mapped images, but I'm trying to carry out the colour pattern analyses portion of this project with the patternize function. Does this make sense?
Thank you!
Best, Wei Han
Thanks for sharing Wei. When you use alignLan + recolorize, you should be getting a result that can be used for PCA analysis. There should be no need anymore to run rgb extraction, because the colors have already been segmented.
I think this should be a good example:
https://hiweller.rbind.io/post/recolorize-patternize-workflow/
Would thos solve it?
Steven
-------- Original message -------- From: weihanlau @.> Date: 9/1/23 4:42 PM (GMT+01:00) To: StevenVB12/patternize @.> Cc: "Steven M. Van Belleghem" @.>, Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven,
Thank you so much for your really prompt response!
Here is my code, along with the jpg. images in the folder "recolored images" that I used to read back into R as Raster objects with makeList(), and the landmarks list in the folder "RGB landmarks".
https://github.com/weihanlau/Cicindela_Pattern
To make the recolored images, I read the original images with patternize functions and ran alignLan() on them, before convertingthe rasters into arrays and running recolorize functions on them to make a universal colour palette. I then exported the recolorized objects as jpgs. and used those jpgs. in the code listed on github. Since they were already aligned, my landmarks that I used in patLanRGB() are all the same. I'm using recolorize to create simplified colour-mapped images, but I'm trying to carry out the colour pattern analyses portion of this project with the patternize function. Does this make sense?
Thank you!
Best, Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1702865927, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC46IE5Y6VZ47P4PWUWDXYHX5NANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.***>
Hi Steven!
Yes, I actually was following Hannah Weller's example on using recolorize and patternize together. The custom function patPCA_total() worked in my case, but everything else didn't.
I wasn't quite sure how to interpret the loadings given by patPCA_total(), so I thought it would be better to follow the regular workflow in patternize to visualize heat maps and see the sources of variation that the PCA was working with. But none of that really worked out. Running a regular patPCA() did give me the same PCA plot, but the heatmap cartoons for the axes min and max were non-existent, so I thought that it would be best to go back, export the recolored images as jpgs., and start from scratch while working entirely in patternize.
I'm so sorry if I'm not understanding things correctly here.
Thank you so much!
Wei Han
No worries, maybe you can send me those earlier results and I will ha e a look at it. Getting heatmaps for specific colors should be possible too.
Steven
-------- Original message -------- From: weihanlau @.> Date: 9/1/23 5:37 PM (GMT+01:00) To: StevenVB12/patternize @.> Cc: "Steven M. Van Belleghem" @.>, Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven!
Yes, I actually was following Hannah Weller's example on using recolorize and patternize together. The custom function patPCA_total() worked in my case, but everything else didn't.
I wasn't quite sure how to interpret the loadings given by patPCA_total(), so I thought it would be better to follow the regular workflow in patternize to visualize heat maps and see the sources of variation that the PCA was working with. But none of that really worked out. Running a regular patPCA() did give me the same PCA plot, but the heatmap cartoons for the axes min and max were non-existent, so I thought that it would be best to go back, export the recolored images as jpgs., and start from scratch while working entirely in patternize.
I'm so sorry if I'm not understanding things correctly here.
Thank you so much!
Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1702946020, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC42MSZC2MEKGSMISBETXYH6NFANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.***>
Will do! I'm going to put it in a new repository in a minute. Thanks!
Hi Steven,
Here's the requested code for the aforementioned earlier results: https://github.com/weihanlau/Cicindela_Recolorize
Here are some of the outputs for that code. The custom function patPCA_total() returns a PCA plot as follows:
And my attempt at running the same thing in patPCA() returns a similar plot. However, as you can see below, the min and max cartoons don't really work out in this plot. Plotting heatmaps don't work with the same data (for the same reasons I presume).
Thank you so much!
Best, Wei Han
Thanks Wei, please give me a couple of days.
Best,
Steven
-------- Original message -------- From: weihanlau @.> Date: 9/1/23 8:37 PM (GMT+01:00) To: StevenVB12/patternize @.> Cc: "Steven M. Van Belleghem" @.>, Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven,
Here's the requested code for the aforementioned earlier results: https://github.com/weihanlau/Cicindela_Recolorize
Here are some of the outputs for that code. The custom function patPCA_total() returns a PCA plot as follows:
And my attempt at running the same thing in patPCA() returns a similar plot. However, as you can see below, the min and max cartoons don't really work out in this plot. Plotting heatmaps don't work with the same data (for the same reasons I presume).
Thank you so much!
Best, Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1703177890, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC445XVQY3CCI7W37MWDXYITPZANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.***>
Absolutely! I'm really grateful for all of your help!
Thanks!
Wei Han
Hi Wei,
I made a few minimal changes and now it works (you just needed to work with ‘patternize_list2’ because patternize needs to know the location of the landmarks relative to the extent of the target image. Now you should see some brain-like summary plots appearing.
If you want those split up per population, I think you best add some code to extract those populations as sets from the total list of rasterstacks.
Also, the plots in the PCA for the multiple colors may not be what you will want in the end. I could send you some code to reconstruct color patterns from any PCA values so that you could make your own representations and place them along the axes.
Let me know what you think.
Best,
Steven
From: weihanlau @.> Sent: Friday, 1 September 2023 20:38 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven,
Here's the requested code for the aforementioned earlier results: https://github.com/weihanlau/Cicindela_Recolorize
Here are some of the outputs for that code. The custom function patPCA_total() returns a PCA plot as follows:
And my attempt at running the same thing in patPCA() returns a similar plot. However, as you can see below, the min and max cartoons don't really work out in this plot. Plotting heatmaps don't work with the same data (for the same reasons I presume).
Thank you so much!
Best, Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1703177890, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC445XVQY3CCI7W37MWDXYITPZANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.**@.>>
Hi Steven!
Oh, yes! That's really such a simple thing that I should have definitely caught. Thank you so much for pointing it out!
I do see the "brain" heat map now in the min and max cartoons after running patPCA(). They seem a little offset from the cartoon, but I think I should be able to figure how to align them up.
You're right that these patterns aren't exactly what I want to double down on right now. For one, I'm not particularly sure what to do with, or how to interpret, the min and max colour pattern heat maps that I have right now from the PC analysis. I think part of the confusion I have stems from how the variation that patternize is detecting is sourced from a combination of different colours in my example right now, so it appears a little tricky to tease apart what trends there might be in the data (e.g. blue represents a negative increment or a depletion, but of which colour?). Do let me know if I am completely misunderstanding this.
I would love to get your custom code to reconstruct colour patterns from any PCA values! Would that mean working with individual colours (and the patterns those colours make?)
I'm also still trying to generate heatmaps for specific colours too, which is why I was using the patLanRGB() method earlier. One of my primary goals here is to characterize maculation patterns (the lighter coloured regions of these beetles). Extracting patterns from RGB values, and then later running a PCA on that, seems the most intuitive approach here. I still don't seem to be able to do this, though, and I find that quite strange. Here's what I'm still getting with patLanRGB( .....plot = "stack") (from the code in the first repository).
Thank you so much for all of your time! I'm so sorry for the high degree of confusion here.
Best, Wei Han
Hi Wei,
The issue with the patLanRGB is that it crops the image based on the landmarks (yours are close to each other). If you add cropOffset = c(200,200,200,200) to get a bigger area, it works for me.
patlanRGB <- patLanRGB(samplejpg, landmarkListRGB, RGBmaculation, colOffset = 0.15, transformRef = landmarkListRGB[["CNC1151335"]], res=300, cropOffset = c(200,200,200,200), resampleFactor = 1, adjustCoords = T, plot = "compare")
I have some code here for recreating (3) colors along the PC axes (what should the pattern look like for max or min value along that axes), maybe that could also work for you. It starts by combining a rasterlist of each of the 3 colors. Maybe you can give this a try?
Steven
############
rList <- list(rasterList_Yellow_M3, rasterList_Red_M3, rasterList_Black_M3)
PCx = 1 PCy = 2
############
print("making dataframe from rasters")
print(paste('number of colors expected:', length(rList))) print(paste('number of individuals expected:', length(rList[[1]]))) print(paste('number of rows expected per raster:', nrow(raster::as.data.frame(rList[[l]][[r]]))))
rasDFstack <- c() for(l in 1:length(rList)){
rasDF <- c()
for(r in 1:length(rList[[l]])){
rList[[l]][[r]][is.na(rList[[l]][[r]])] <- 0
ras <- raster::as.data.frame(rList[[l]][[r]])
colnames(ras) <- names(rList[[l]])[[r]]
if(r == 1){
rasDF <- ras
}
else{
rasDF <- cbind(rasDF, ras)
}
} rasDFstack <- rbind(rasDFstack, rasDF) }
############
print("calculating prcomp")
comp <- prcomp(t(rasDFstack))
pcdata <- comp$x rotation <- comp$rotation
summ <- summary(comp)
xmin <- min(pcdata[,PCx]) xmax <- max(pcdata[,PCx]) ymin <- min(pcdata[,PCy]) ymax <- max(pcdata[,PCy])
par(mfrow=c(1,1), mar=c(4,4,2,2)) plot(comp$x[,c(PCx,PCy)], col='red', pch=19, xlim = c(xmin, xmax), ylim = c(ymin, ymax), xlab=paste('PC',PCx,' (', round(summ$importance[2,PCx]100, 1), ' %)'), ylab=paste('PC',PCy,' (', round(summ$importance[2,PCy]100, 1), ' %)'))
############
print("calculating changes")
PCxmin <- min(pcdata[,PCx]) PCxmax <- max(pcdata[,PCx])
PCymin <- min(pcdata[,PCy]) PCymax <- max(pcdata[,PCy])
pc.vecMix <- rep(0, dim(pcdata)[1]) pc.vecMix[PCx] <- PCxmin
pc.vecMax <- rep(0, dim(pcdata)[1]) pc.vecMax[PCx] <- PCxmax
pc.vecMiy <- rep(0, dim(pcdata)[1]) pc.vecMiy[PCy] <- PCymin
pc.vecMay <- rep(0, dim(pcdata)[1]) pc.vecMay[PCy] <- PCymax
xMi <- pc.vecMix %% t(rotation) xMa <- pc.vecMax %% t(rotation)
yMi <- pc.vecMiy %% t(rotation) yMa <- pc.vecMay %% t(rotation)
NrRows <- nrow(rasDFstack)/length(rList)
start <- 1 end <- NrRows
mapMix_All <- c() mapMax_All <- c() mapMiy_All <- c() mapMay_All <- c()
for(e in 1:length(rList)){
xMi_sub <- xMi[start:end] xMa_sub <- xMa[start:end]
yMi_sub <- yMi[start:end] yMa_sub <- yMa[start:end]
x2Mi <- t(matrix(xMi_sub, ncol = dim(rList[[1]][[1]])[1], nrow = dim(rList[[1]][[1]])[2])) x2Ma <- t(matrix(xMa_sub, ncol = dim(rList[[1]][[1]])[1], nrow = dim(rList[[1]][[1]])[2]))
y2Mi <- t(matrix(yMi_sub, ncol = dim(rList[[1]][[1]])[1], nrow = dim(rList[[1]][[1]])[2])) y2Ma <- t(matrix(yMa_sub, ncol = dim(rList[[1]][[1]])[1], nrow = dim(rList[[1]][[1]])[2]))
mapMix <-raster::raster(x2Mi) mapMax <-raster::raster(x2Ma)
mapMiy <-raster::raster(y2Mi) mapMay <-raster::raster(y2Ma)
raster::extent(mapMix) <- raster::extent(rList[[1]][[1]]) raster::extent(mapMax) <- raster::extent(rList[[1]][[1]])
raster::extent(mapMiy) <- raster::extent(rList[[1]][[1]]) raster::extent(mapMay) <- raster::extent(rList[[1]][[1]])
mapMix_All <- c(mapMix_All, mapMix) mapMax_All <- c(mapMax_All, mapMax) mapMiy_All <- c(mapMiy_All, mapMiy) mapMay_All <- c(mapMay_All, mapMay)
start <- start + NrRows end <- end + NrRows
}
par(mfrow=c(3,1)) raster::plot(mapMix_All[[1]]) raster::plot(mapMix_All[[2]]) raster::plot(mapMix_All[[3]])
colf <- colorRampPalette(c("blue","lightblue","black","indianred1","firebrick1")) colfunc <- colf(100)
layout(matrix(c(1:6), nrow=2, byrow=FALSE)) layout.show(n=6)
titles <- c('yellow', 'red', 'black') for(e in 1:length(mapMix_All)){
plotHeat(mapMax_All[[e]]/max(abs(raster::as.data.frame(mapMax_All[[e]]))), IDlist, plotCartoon = TRUE, refShape = target, outline = outline_642, lines = lines_642, landList = landmarkList, adjustCoords = TRUE, flipRaster = 'y', imageList = imageList, cartoonID = '642_side', cartoonFill = 'black', cartoonCol = 'gray35', cartoonOrder = 'under', colpalette = colfunc, zlim = c(-1,1), legend = F, normalized = T, plotType = 'PCA')
mtext(titles[e], side=3) if(e==1){mtext('max', side=2)}
plotHeat(mapMix_All[[e]]/max(abs(raster::as.data.frame(mapMix_All[[e]]))), IDlist, plotCartoon = TRUE, refShape = target, outline = outline_642, lines = lines_642, landList = landmarkList, adjustCoords = TRUE, flipRaster = 'y', imageList = imageList, cartoonID = '642_side', cartoonFill = 'black', cartoonCol = 'gray35', cartoonOrder = 'under', colpalette = colfunc, zlim = c(-1,1), legend = F, normalized = T, plotType = 'PCA')
if(e==1){mtext('min', side=2)} }
for(e in 1:length(mapMix_All)){
plotHeat(mapMay_All[[e]]/max(abs(raster::as.data.frame(mapMay_All[[e]]))), IDlist, plotCartoon = TRUE, refShape = target, outline = outline_642, lines = lines_642, landList = landmarkList, adjustCoords = TRUE, flipRaster = 'y', imageList = imageList, cartoonID = '642_side', cartoonFill = 'black', cartoonCol = 'gray35', cartoonOrder = 'under', colpalette = colfunc, zlim = c(-1,1), legend = F, normalized = T, plotType = 'PCA')
mtext(titles[e], side=3) if(e==1){mtext('max', side=2)}
plotHeat(mapMiy_All[[e]]/max(abs(raster::as.data.frame(mapMiy_All[[e]]))), IDlist, plotCartoon = TRUE, refShape = target, outline = outline_642, lines = lines_642, landList = landmarkList, adjustCoords = TRUE, flipRaster = 'y', imageList = imageList, cartoonID = '642_side', cartoonFill = 'black', cartoonCol = 'gray35', cartoonOrder = 'under', colpalette = colfunc, zlim = c(-1,1), legend = F, normalized = T, plotType = 'PCA') if(e==1){mtext('min', side=2)} }
From: weihanlau @.> Sent: Tuesday, 5 September 2023 23:05 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven!
Oh, yes! That's really such a simple thing that I should have definitely caught. Thank you so much for pointing it out!
I do see the "brain" heat map now in the min and max cartoons after running patPCA(). They seem a little offset from the cartoon, but I think I should be able to figure how to align them up.
You're right that these patterns aren't exactly what I want to double down on right now. For one, I'm not particularly sure what to do with, or how to interpret, the min and max colour pattern heat maps that I have right now from the PC analysis. I think part of the confusion I have stems from how the variation that patternize is detecting is sourced from a combination of different colours in my example right now, so it appears a little tricky to tease apart what trends there might be in the data (e.g. blue represents a negative increment or a depletion, but of which colour?). Do let me know if I am completely misunderstanding this.
I would love to get your custom code to reconstruct colour patterns from any PCA values! Would that mean working with individual colours (and the patterns those colours make?)
I'm also still trying to generate heatmaps for specific colours too, which is why I was using the patLanRGB() method earlier. One of my primary goals here is to characterize maculation patterns (the lighter coloured regions of these beetles). Extracting patterns from RGB values, and then later running a PCA on that, seems the most intuitive approach here. I still don't seem to be able to do this, though, and I find that quite strange. Here's what I'm still getting with patLanRGB( .....plot = "stack") (from the code in the first repository).
Thank you so much for all of your time! I'm so sorry for the high degree of confusion here.
Best, Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1707309262, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC454OMANWFJ7HG3CFWDXY6HY3ANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.**@.>>
Thank you so much Steven!
Everything works beautifully now! I really appreciate all of your help!
One last quick question: I'm getting some slightly strange results from patPCA(). I'm running the function with just 5 specimens right now, but the position of each specimen seems to get jumbled in between runs of the same function with the exact same data. I get the same distribution pattern but, the location of each specimen point in the PCA seems to change. Part of this seems to be related to how I define the population list and colour list for the function. For example, when the population list and colour list is defined like so:
pop1 <- c("CNC1151335") pop3 <- c("CNC1860123", "CNC1860122") pop2 <- c("CNC1860300", "CNC1151393") popList <- list(pop2, pop3, pop1) colList <- c("blue", "darkgreen", "red") symbolList <- c(18, 18, 18)
I get the following plot:
However, when I tweak things a little like this:
pop1 <- c("CNC1151335") pop3 <- c("CNC1860123", "CNC1860122") pop2 <- c("CNC1860300") pop4 <- c("CNC1151393") popList <- list(pop2, pop3, pop1, pop4) colList <- c("blue", "darkgreen", "red", "purple") symbolList <- c(18, 18, 18, 18)
I get this plot (with specimen CNC1151335 switching positions):
Do you know why this is the case?
Thanks, as always!
Wei Han
Hi Wei Han,
I believe your colList should repeat the colors so that it has the same total length as the total number of samples (same for symbolist I think). E.g. using rep(“blue”, length(pop1))
Hope that works!
Steven
From: weihanlau @.> Sent: Thursday, 7 September 2023 18:55 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Thank you so much Steven!
Everything works beautifully now! I really appreciate all of your help!
One last quick question: I'm getting some slightly strange results from patPCA(). I'm running the function with just 5 specimens right now, but the position of each specimen seems to get jumbled in between runs of the same function with the exact same data. I get the same distribution pattern but, the location of each specimen point in the PCA seems to change. Part of this seems to be related to how I define the population list and colour list for the function. For example, when the population list and colour list is defined like so:
pop1 <- c("CNC1151335") pop3 <- c("CNC1860123", "CNC1860122") pop2 <- c("CNC1860300", "CNC1151393") popList <- list(pop2, pop3, pop1) colList <- c("blue", "darkgreen", "red") symbolList <- c(18, 18, 18)
I get the following plot:
[image]https://user-images.githubusercontent.com/116670367/266386724-23173eab-dc15-4c82-9f78-d00755cd0453.png [image]https://user-images.githubusercontent.com/116670367/266387491-1c377d40-0f0c-42c3-96db-1d06c4bb0e02.png
However, when I tweak things a little like this:
pop1 <- c("CNC1151335") pop3 <- c("CNC1860123", "CNC1860122") pop2 <- c("CNC1860300") pop4 <- c("CNC1151393") popList <- list(pop2, pop3, pop1, pop4) colList <- c("blue", "darkgreen", "red", "purple") symbolList <- c(18, 18, 18, 18)
I get this plot (with specimen CNC1860300 switching positions):
[image]https://user-images.githubusercontent.com/116670367/266388177-25b4ea87-725e-4da2-9a1c-3deb85546656.png [image]https://user-images.githubusercontent.com/116670367/266388249-95d1d42d-741e-489f-b6d4-99d17a3fc4d6.png
Do you know why this is the case?
Thanks, as always!
Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1710491183, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC4ZEHFWDDSKYZAVRPETXZH4ABANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.**@.>>
Hm, it doesn't quite work. Colours get reused, and it seems that it simply matters where the colours are indexed in the list and how populations are indexed? I'm still getting some inconsistent placing of specimens across runs. colList[3] is still red in this case, as it should be.
pop1 <- c("CNC1151335") pop2 <- c("CNC1860123", "CNC1860122") pop3 <- c("CNC1860300", "CNC1151393")
popList <- list(pop1, pop2, pop3) colList <- c(rep("blue", length(pop1)), rep("red", length(pop2)), rep("green", length(pop2))) symbolList <- c(rep(18, length(pop1)), rep(18, length(pop2)), rep(18, length(pop3)))
I see! I got confused. Something seems wrong with the code. The order of the samples indeed doesn’t seem to match the order of the colors anymore. I’m confused why I haven’t had that problem before. I’ll work on a solution.
Steven
From: weihanlau @.> Sent: Thursday, 7 September 2023 22:37 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hm, it doesn't quite work. Colours get reused, and it seems that it simply matters where the colours are indexed in the list and how populations are indexed? I'm still getting some inconsistent placing of specimens across runs. colList[3] is still red in this case, as it should be.
pop1 <- c("CNC1151335") pop2 <- c("CNC1860123", "CNC1860122") pop3 <- c("CNC1860300", "CNC1151393")
popList <- list(pop1, pop2, pop3) colList <- c(rep("blue", length(pop1)), rep("red", length(pop2)), rep("green", length(pop2))) symbolList <- c(rep(18, length(pop1)), rep(18, length(pop2)), rep(18, length(pop3)))
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1710739170, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC4ZRV2LZ6EHUISJCYZLXZIV5DANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.**@.>>
Thanks Steven!
The code for this is from here (https://github.com/weihanlau/Cicindela_Pattern/blob/main/Cicindela_formosa_PATTERNRC.Rmd)
Part of the concern here is that I'm not seeing the patterns that I was expecting (and what I got from follow Hannah Weller's methods).
The "bare" beetle (CNC1151335 ) being by itself at the top left representing the maxima for PC1, and the two "brain" like looking beetle patterns (CNC1860122, CNC1860123) clustered on the right representing the maxima for PC2.
With patPCA(), the distribution is the same as what I got from following Hannah Weller's methods and using the custom function patPCA_total(), but oddly enough, the specimen locations on the PC axes turn out to be different.
Wei Han
Hi Wei Han,
I resolved the issue. It occurs because I usually keep samples of populations separate and then the order of populations and colors usually matches. With the additions of recolorize that’s not always the case anymore. So thanks for noticing this!!
You’ll have to reinstall patternize from guthub for it to work. You’ll also have to add this line of code to your script so that your combined raster list includes the names of the samples again.
names(patternize_merged) <- c('CNC1151335','CNC1151393', 'CNC1860122','CNC1860123','CNC1860300')
Note also that patPCA() will not deal well with the PCA results that come from more than one color. I think it would be better to run the PCA for the combine colors, but generate the predicted phenotypes along the axes for the separate colors, if that makes sense (using the example code I sent earlier). Let me know if you’d need further help with that.
Best,
Steven
From: weihanlau @.> Sent: Friday, 8 September 2023 00:25 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Thanks Steven!
The code for this is from here (https://github.com/weihanlau/Cicindela_Pattern/blob/main/Cicindela_formosa_PATTERNRC.Rmd)
Part of the concern here is that I'm not seeing the patterns that I was expecting and what I got from follow Hannah Weller's methods.
The "bare" beetle being by itself at the top left representing the maxima for PC1, and the two "brain" like looking beetle patterns being by itself on the right representing the maxima for PC2.
With patPCA(), the distribution is the same, but oddly enough the specimen locations on the PC axes are different.
Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1710838219, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC47EXEKHKKDNMWEE74DXZJCUZANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.**@.>>
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
Hi Wei Han,
Exciting to hear it’s working.
The best I can suggest at this point is indeed to recreate predicted phenotypes at the max and min values of a PC axis (and assuming a value of 0 for other PC axes). This is essentially what the patPCA function shows for one color and it should show the main phenotypic variation that occurs along the axes. For multiple colors I agree it gets complicated and if you want, I can past some code into yours to create phenotypes for any PC values. I think that can help you explore the changes and loadings of the PC axes.
I think this should do the trick and give you the output of the prcomp command:
Out <- patPCA() comp <- Out[[3]] comp$x
Hope this helps,
Steven
From: weihanlau @.> Sent: Friday, 29 September 2023 07:55 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1740350098, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC456JFCDN4HKG5NXWS3X4ZPETANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.**@.>>
Thank you Steven!
My plot looks lovely! Do you know how to maintain the groupings in the prcomp objected extracted from the patPCA function? The groupings (populations, in our case) are extrinsically defined before running the patPCA function, so they do not appear to be in the dataset.
Also, I've been fighting the outline and raster disparity all week in my patPCA function. Do you know if there's a fix to this? I have tried flipOutline and flipRaster to no avail.
[image: image.png] I would definitely love to have the code for the creation of phenotypes for any PC value! Thanks for that! Working with that might have to be something I explore down the line a little later on once I get over a current hump of work, though.
Best, Wei Han
On Fri, 29 Sept 2023 at 07:25, Steven M. Van Belleghem < @.***> wrote:
Hi Wei Han,
Exciting to hear it’s working.
The best I can suggest at this point is indeed to recreate predicted phenotypes at the max and min values of a PC axis (and assuming a value of 0 for other PC axes). This is essentially what the patPCA function shows for one color and it should show the main phenotypic variation that occurs along the axes. For multiple colors I agree it gets complicated and if you want, I can past some code into yours to create phenotypes for any PC values. I think that can help you explore the changes and loadings of the PC axes.
I think this should do the trick and give you the output of the prcomp command:
Out <- patPCA() comp <- Out[[3]] comp$x
Hope this helps,
Steven
From: weihanlau @.> Sent: Friday, 29 September 2023 07:55 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740350098>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC456JFCDN4HKG5NXWS3X4ZPETANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.>>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740894483, or unsubscribe https://github.com/notifications/unsubscribe-auth/A32D7H4BKGL5BSFA5NE7ZGDX43D4JANCNFSM6AAAAAA4HBYVXU . You are receiving this because you authored the thread.Message ID: @.***>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @. Secondary - @. "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
Hi Wei Han,
I hope this would do what you need:
Out <- patPCA() groupCol <- Out[[2]]
That object should be a table with the correct order of the labels.
I’m not sure what is causing the disparity. To make sure it’s not an issue with my code, could you share me what you got (script, landmarks, …)? I’ll also try adding the code for creating phenotypes.
Best,
Steven
From: weihanlau @.> Sent: Sunday, 1 October 2023 22:22 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Thank you Steven!
My plot looks lovely! Do you know how to maintain the groupings in the prcomp objected extracted from the patPCA function? The groupings (populations, in our case) are extrinsically defined before running the patPCA function, so they do not appear to be in the dataset.
Also, I've been fighting the outline and raster disparity all week in my patPCA function. Do you know if there's a fix to this? I have tried flipOutline and flipRaster to no avail.
[image: image.png] I would definitely love to have the code for the creation of phenotypes for any PC value! Thanks for that! Working with that might have to be something I explore down the line a little later on once I get over a current hump of work, though.
Best, Wei Han
On Fri, 29 Sept 2023 at 07:25, Steven M. Van Belleghem < @.<mailto:@.>> wrote:
Hi Wei Han,
Exciting to hear it’s working.
The best I can suggest at this point is indeed to recreate predicted phenotypes at the max and min values of a PC axis (and assuming a value of 0 for other PC axes). This is essentially what the patPCA function shows for one color and it should show the main phenotypic variation that occurs along the axes. For multiple colors I agree it gets complicated and if you want, I can past some code into yours to create phenotypes for any PC values. I think that can help you explore the changes and loadings of the PC axes.
I think this should do the trick and give you the output of the prcomp command:
Out <- patPCA() comp <- Out[[3]] comp$x
Hope this helps,
Steven
From: weihanlau @.<mailto:@.>> Sent: Friday, 29 September 2023 07:55 To: StevenVB12/patternize @.<mailto:@.>> Cc: Steven M. Van Belleghem @.<mailto:@.>>; Comment @.<mailto:@.>> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740350098>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC456JFCDN4HKG5NXWS3X4ZPETANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***>>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740894483, or unsubscribe https://github.com/notifications/unsubscribe-auth/A32D7H4BKGL5BSFA5NE7ZGDX43D4JANCNFSM6AAAAAA4HBYVXU . You are receiving this because you authored the thread.Message ID: @.<mailto:@.>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1742190690, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC446OIXUVYFW7EN5NMLX5HGGFANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.**@.>>
Hi Steven!
Here's the associated code that produced that plot: https://github.com/weihanlau/Cicindela_final
Also, with Out[[2]], I get the loadings again with the associated ID's. What I was trying to get was the data frame that produced the prcomp to add a column to specify each specimen's population (defined earlier before patPCA), so I can visualize that on a regular autoplot. No matter though! I think I can figure this one out!
Thank you!
Wei Han
On Sun, 1 Oct 2023 at 14:34, Steven M. Van Belleghem < @.***> wrote:
Hi Wei Han,
I hope this would do what you need:
Out <- patPCA() groupCol <- Out[[2]]
That object should be a table with the correct order of the labels.
I’m not sure what is causing the disparity. To make sure it’s not an issue with my code, could you share me what you got (script, landmarks, …)? I’ll also try adding the code for creating phenotypes.
Best,
Steven
From: weihanlau @.> Sent: Sunday, 1 October 2023 22:22 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Thank you Steven!
My plot looks lovely! Do you know how to maintain the groupings in the prcomp objected extracted from the patPCA function? The groupings (populations, in our case) are extrinsically defined before running the patPCA function, so they do not appear to be in the dataset.
Also, I've been fighting the outline and raster disparity all week in my patPCA function. Do you know if there's a fix to this? I have tried flipOutline and flipRaster to no avail.
[image: image.png] I would definitely love to have the code for the creation of phenotypes for any PC value! Thanks for that! Working with that might have to be something I explore down the line a little later on once I get over a current hump of work, though.
Best, Wei Han
On Fri, 29 Sept 2023 at 07:25, Steven M. Van Belleghem < @.<mailto:@.>> wrote:
Hi Wei Han,
Exciting to hear it’s working.
The best I can suggest at this point is indeed to recreate predicted phenotypes at the max and min values of a PC axis (and assuming a value of 0 for other PC axes). This is essentially what the patPCA function shows for one color and it should show the main phenotypic variation that occurs along the axes. For multiple colors I agree it gets complicated and if you want, I can past some code into yours to create phenotypes for any PC values. I think that can help you explore the changes and loadings of the PC axes.
I think this should do the trick and give you the output of the prcomp command:
Out <- patPCA() comp <- Out[[3]] comp$x
Hope this helps,
Steven
From: weihanlau @.<mailto:@.>> Sent: Friday, 29 September 2023 07:55 To: StevenVB12/patternize @.<mailto:@.>> Cc: Steven M. Van Belleghem @.<mailto:@.>>; Comment @.<mailto:@.>> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740350098>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC456JFCDN4HKG5NXWS3X4ZPETANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***>>
— Reply to this email directly, view it on GitHub < https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740894483>,
or unsubscribe < https://github.com/notifications/unsubscribe-auth/A32D7H4BKGL5BSFA5NE7ZGDX43D4JANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742190690>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC446OIXUVYFW7EN5NMLX5HGGFANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.>>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742193698, or unsubscribe https://github.com/notifications/unsubscribe-auth/A32D7H44LR47UYJMSSJWNC3X5HHURANCNFSM6AAAAAA4HBYVXU . You are receiving this because you authored the thread.Message ID: @.***>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @. Secondary - @. "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
Hi Wei Han,
Strange, Out[[2]] should be a table with the colors and label assignments and the rows in the same order as the samples in the PCA from prcomp$x. So that should allow you to easily produce a plot yourself.
I hope I can attend to your other issue soon!
Steven
From: weihanlau @.> Sent: Sunday, 1 October 2023 23:04 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven!
Here's the associated code that produced that plot: https://github.com/weihanlau/Cicindela_final
Also, with Out[[2]], I get the loadings again with the associated ID's. What I was trying to get was the data frame that produced the prcomp to add a column to specify each specimen's population (defined earlier before patPCA), so I can visualize that on a regular autoplot. No matter though! I think I can figure this one out!
Thank you!
Wei Han
On Sun, 1 Oct 2023 at 14:34, Steven M. Van Belleghem < @.<mailto:@.>> wrote:
Hi Wei Han,
I hope this would do what you need:
Out <- patPCA() groupCol <- Out[[2]]
That object should be a table with the correct order of the labels.
I’m not sure what is causing the disparity. To make sure it’s not an issue with my code, could you share me what you got (script, landmarks, …)? I’ll also try adding the code for creating phenotypes.
Best,
Steven
From: weihanlau @.<mailto:@.>> Sent: Sunday, 1 October 2023 22:22 To: StevenVB12/patternize @.<mailto:@.>> Cc: Steven M. Van Belleghem @.<mailto:@.>>; Comment @.<mailto:@.>> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Thank you Steven!
My plot looks lovely! Do you know how to maintain the groupings in the prcomp objected extracted from the patPCA function? The groupings (populations, in our case) are extrinsically defined before running the patPCA function, so they do not appear to be in the dataset.
Also, I've been fighting the outline and raster disparity all week in my patPCA function. Do you know if there's a fix to this? I have tried flipOutline and flipRaster to no avail.
[image: image.png] I would definitely love to have the code for the creation of phenotypes for any PC value! Thanks for that! Working with that might have to be something I explore down the line a little later on once I get over a current hump of work, though.
Best, Wei Han
On Fri, 29 Sept 2023 at 07:25, Steven M. Van Belleghem < @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> wrote:
Hi Wei Han,
Exciting to hear it’s working.
The best I can suggest at this point is indeed to recreate predicted phenotypes at the max and min values of a PC axis (and assuming a value of 0 for other PC axes). This is essentially what the patPCA function shows for one color and it should show the main phenotypic variation that occurs along the axes. For multiple colors I agree it gets complicated and if you want, I can past some code into yours to create phenotypes for any PC values. I think that can help you explore the changes and loadings of the PC axes.
I think this should do the trick and give you the output of the prcomp command:
Out <- patPCA() comp <- Out[[3]] comp$x
Hope this helps,
Steven
From: weihanlau @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> Sent: Friday, 29 September 2023 07:55 To: StevenVB12/patternize @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> Cc: Steven M. Van Belleghem @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>; Comment @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740350098>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC456JFCDN4HKG5NXWS3X4ZPETANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***<mailto:***@***.******@***.***%3cmailto:***@***.******@***.***>>>
— Reply to this email directly, view it on GitHub < https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740894483>,
or unsubscribe < https://github.com/notifications/unsubscribe-auth/A32D7H4BKGL5BSFA5NE7ZGDX43D4JANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***> Secondary - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742190690>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC446OIXUVYFW7EN5NMLX5HGGFANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***>>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742193698, or unsubscribe https://github.com/notifications/unsubscribe-auth/A32D7H44LR47UYJMSSJWNC3X5HHURANCNFSM6AAAAAA4HBYVXU . You are receiving this because you authored the thread.Message ID: @.<mailto:@.>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1742201147, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC44ZJDTDFYDEE7RM6I3X5HLDLANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.**@.>>
Hmm let me look at that again (there's always a very high probability that I'm getting things wrong on my end)
Thanks!
Wei Han
On Sun, 1 Oct 2023 at 15:08, Steven M. Van Belleghem < @.***> wrote:
Hi Wei Han,
Strange, Out[[2]] should be a table with the colors and label assignments and the rows in the same order as the samples in the PCA from prcomp$x. So that should allow you to easily produce a plot yourself.
I hope I can attend to your other issue soon!
Steven
From: weihanlau @.> Sent: Sunday, 1 October 2023 23:04 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven!
Here's the associated code that produced that plot: https://github.com/weihanlau/Cicindela_final
Also, with Out[[2]], I get the loadings again with the associated ID's. What I was trying to get was the data frame that produced the prcomp to add a column to specify each specimen's population (defined earlier before patPCA), so I can visualize that on a regular autoplot. No matter though! I think I can figure this one out!
Thank you!
Wei Han
On Sun, 1 Oct 2023 at 14:34, Steven M. Van Belleghem < @.<mailto:@.>> wrote:
Hi Wei Han,
I hope this would do what you need:
Out <- patPCA() groupCol <- Out[[2]]
That object should be a table with the correct order of the labels.
I’m not sure what is causing the disparity. To make sure it’s not an issue with my code, could you share me what you got (script, landmarks, …)? I’ll also try adding the code for creating phenotypes.
Best,
Steven
From: weihanlau @.<mailto:@.>> Sent: Sunday, 1 October 2023 22:22 To: StevenVB12/patternize @.<mailto:@.>> Cc: Steven M. Van Belleghem @.<mailto:@.>>; Comment @.<mailto:@.>> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Thank you Steven!
My plot looks lovely! Do you know how to maintain the groupings in the prcomp objected extracted from the patPCA function? The groupings (populations, in our case) are extrinsically defined before running the patPCA function, so they do not appear to be in the dataset.
Also, I've been fighting the outline and raster disparity all week in my patPCA function. Do you know if there's a fix to this? I have tried flipOutline and flipRaster to no avail.
[image: image.png] I would definitely love to have the code for the creation of phenotypes for any PC value! Thanks for that! Working with that might have to be something I explore down the line a little later on once I get over a current hump of work, though.
Best, Wei Han
On Fri, 29 Sept 2023 at 07:25, Steven M. Van Belleghem < @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> wrote:
Hi Wei Han,
Exciting to hear it’s working.
The best I can suggest at this point is indeed to recreate predicted phenotypes at the max and min values of a PC axis (and assuming a value of 0 for other PC axes). This is essentially what the patPCA function shows for one color and it should show the main phenotypic variation that occurs along the axes. For multiple colors I agree it gets complicated and if you want, I can past some code into yours to create phenotypes for any PC values. I think that can help you explore the changes and loadings of the PC axes.
I think this should do the trick and give you the output of the prcomp command:
Out <- patPCA() comp <- Out[[3]] comp$x
Hope this helps,
Steven
From: weihanlau @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Sent: Friday, 29 September 2023 07:55 To: StevenVB12/patternize @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Cc: Steven M. Van Belleghem @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>; Comment @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue
42)
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740350098>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC456JFCDN4HKG5NXWS3X4ZPETANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***<mailto:***@***.******@***.***%3cmailto:***@***.******@***.***>>>
— Reply to this email directly, view it on GitHub <
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740894483>,
or unsubscribe <
https://github.com/notifications/unsubscribe-auth/A32D7H4BKGL5BSFA5NE7ZGDX43D4JANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>
Secondary - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>
"It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742190690>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC446OIXUVYFW7EN5NMLX5HGGFANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***>>
— Reply to this email directly, view it on GitHub < https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742193698>,
or unsubscribe < https://github.com/notifications/unsubscribe-auth/A32D7H44LR47UYJMSSJWNC3X5HHURANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742201147>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC44ZJDTDFYDEE7RM6I3X5HLDLANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.>>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742202416, or unsubscribe https://github.com/notifications/unsubscribe-auth/A32D7H6O4MK5XEMJGEMZWBLX5HLV5ANCNFSM6AAAAAA4HBYVXU . You are receiving this because you authored the thread.Message ID: @.***>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @. Secondary - @. "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
You were right! So sorry about that mix up! The groupings work great!
Wei Han
On Sun, 1 Oct 2023 at 15:12, Wei Han Lau @.***> wrote:
Hmm let me look at that again (there's always a very high probability that I'm getting things wrong on my end)
Thanks!
Wei Han
On Sun, 1 Oct 2023 at 15:08, Steven M. Van Belleghem < @.***> wrote:
Hi Wei Han,
Strange, Out[[2]] should be a table with the colors and label assignments and the rows in the same order as the samples in the PCA from prcomp$x. So that should allow you to easily produce a plot yourself.
I hope I can attend to your other issue soon!
Steven
From: weihanlau @.> Sent: Sunday, 1 October 2023 23:04 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven!
Here's the associated code that produced that plot: https://github.com/weihanlau/Cicindela_final
Also, with Out[[2]], I get the loadings again with the associated ID's. What I was trying to get was the data frame that produced the prcomp to add a column to specify each specimen's population (defined earlier before patPCA), so I can visualize that on a regular autoplot. No matter though! I think I can figure this one out!
Thank you!
Wei Han
On Sun, 1 Oct 2023 at 14:34, Steven M. Van Belleghem < @.<mailto:@.>> wrote:
Hi Wei Han,
I hope this would do what you need:
Out <- patPCA() groupCol <- Out[[2]]
That object should be a table with the correct order of the labels.
I’m not sure what is causing the disparity. To make sure it’s not an issue with my code, could you share me what you got (script, landmarks, …)? I’ll also try adding the code for creating phenotypes.
Best,
Steven
From: weihanlau @.<mailto:@.>> Sent: Sunday, 1 October 2023 22:22 To: StevenVB12/patternize @.<mailto:@.>> Cc: Steven M. Van Belleghem @.<mailto:@.>>; Comment @.<mailto:@.>> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Thank you Steven!
My plot looks lovely! Do you know how to maintain the groupings in the prcomp objected extracted from the patPCA function? The groupings (populations, in our case) are extrinsically defined before running the patPCA function, so they do not appear to be in the dataset.
Also, I've been fighting the outline and raster disparity all week in my patPCA function. Do you know if there's a fix to this? I have tried flipOutline and flipRaster to no avail.
[image: image.png] I would definitely love to have the code for the creation of phenotypes for any PC value! Thanks for that! Working with that might have to be something I explore down the line a little later on once I get over a current hump of work, though.
Best, Wei Han
On Fri, 29 Sept 2023 at 07:25, Steven M. Van Belleghem < @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> wrote:
Hi Wei Han,
Exciting to hear it’s working.
The best I can suggest at this point is indeed to recreate predicted phenotypes at the max and min values of a PC axis (and assuming a value of 0 for other PC axes). This is essentially what the patPCA function shows for one color and it should show the main phenotypic variation that occurs along the axes. For multiple colors I agree it gets complicated and if you want, I can past some code into yours to create phenotypes for any PC values. I think that can help you explore the changes and loadings of the PC axes.
I think this should do the trick and give you the output of the prcomp command:
Out <- patPCA() comp <- Out[[3]] comp$x
Hope this helps,
Steven
From: weihanlau @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Sent: Friday, 29 September 2023 07:55 To: StevenVB12/patternize @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Cc: Steven M. Van Belleghem @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>; Comment @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue
42)
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740350098>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC456JFCDN4HKG5NXWS3X4ZPETANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***<mailto:***@***.******@***.***%3cmailto:***@***.******@***.***>>>
— Reply to this email directly, view it on GitHub <
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740894483>,
or unsubscribe <
https://github.com/notifications/unsubscribe-auth/A32D7H4BKGL5BSFA5NE7ZGDX43D4JANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>
Secondary - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>
"It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742190690>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC446OIXUVYFW7EN5NMLX5HGGFANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***>>
— Reply to this email directly, view it on GitHub < https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742193698>,
or unsubscribe < https://github.com/notifications/unsubscribe-auth/A32D7H44LR47UYJMSSJWNC3X5HHURANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742201147>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC44ZJDTDFYDEE7RM6I3X5HLDLANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.>>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742202416, or unsubscribe https://github.com/notifications/unsubscribe-auth/A32D7H6O4MK5XEMJGEMZWBLX5HLV5ANCNFSM6AAAAAA4HBYVXU . You are receiving this because you authored the thread.Message ID: @.***>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @. Secondary - @. "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
--
Wei Han - Homeschooler and Arsenal Fan
Main - @. Secondary - @. "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
Hi Wei Han,
I think I resolved the issues.
For the PCA, the following needed to be added:
I added code that predicts phenotypes in the PCA. However, I noticed that it does not predict colors for areas that are invariable. Hance be careful with the interpretation (also for the predicted PCA changes). Alternatively, you could also map the original images in the PCA plot (like Hannah does here: https://hiweller.rbind.io/post/recolorize-patternize-workflow/).
It’s definitely fun to see your results. Does the PCA clustering relate to some geographic gradient?
Hope it works!
Steven
From: weihanlau @.> Sent: Monday, 2 October 2023 05:59 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
You were right! So sorry about that mix up! The groupings were great!
Wei Han
On Sun, 1 Oct 2023 at 15:12, Wei Han Lau @.<mailto:@.>> wrote:
Hmm let me look at that again (there's always a very high probability that I'm getting things wrong on my end)
Thanks!
Wei Han
On Sun, 1 Oct 2023 at 15:08, Steven M. Van Belleghem < @.<mailto:@.>> wrote:
Hi Wei Han,
Strange, Out[[2]] should be a table with the colors and label assignments and the rows in the same order as the samples in the PCA from prcomp$x. So that should allow you to easily produce a plot yourself.
I hope I can attend to your other issue soon!
Steven
From: weihanlau @.<mailto:@.>> Sent: Sunday, 1 October 2023 23:04 To: StevenVB12/patternize @.<mailto:@.>> Cc: Steven M. Van Belleghem @.<mailto:@.>>; Comment @.<mailto:@.>> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven!
Here's the associated code that produced that plot: https://github.com/weihanlau/Cicindela_final
Also, with Out[[2]], I get the loadings again with the associated ID's. What I was trying to get was the data frame that produced the prcomp to add a column to specify each specimen's population (defined earlier before patPCA), so I can visualize that on a regular autoplot. No matter though! I think I can figure this one out!
Thank you!
Wei Han
On Sun, 1 Oct 2023 at 14:34, Steven M. Van Belleghem < @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> wrote:
Hi Wei Han,
I hope this would do what you need:
Out <- patPCA() groupCol <- Out[[2]]
That object should be a table with the correct order of the labels.
I’m not sure what is causing the disparity. To make sure it’s not an issue with my code, could you share me what you got (script, landmarks, …)? I’ll also try adding the code for creating phenotypes.
Best,
Steven
From: weihanlau @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> Sent: Sunday, 1 October 2023 22:22 To: StevenVB12/patternize @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> Cc: Steven M. Van Belleghem @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>; Comment @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Thank you Steven!
My plot looks lovely! Do you know how to maintain the groupings in the prcomp objected extracted from the patPCA function? The groupings (populations, in our case) are extrinsically defined before running the patPCA function, so they do not appear to be in the dataset.
Also, I've been fighting the outline and raster disparity all week in my patPCA function. Do you know if there's a fix to this? I have tried flipOutline and flipRaster to no avail.
[image: image.png] I would definitely love to have the code for the creation of phenotypes for any PC value! Thanks for that! Working with that might have to be something I explore down the line a little later on once I get over a current hump of work, though.
Best, Wei Han
On Fri, 29 Sept 2023 at 07:25, Steven M. Van Belleghem < @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***<mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>> wrote:
Hi Wei Han,
Exciting to hear it’s working.
The best I can suggest at this point is indeed to recreate predicted phenotypes at the max and min values of a PC axis (and assuming a value of 0 for other PC axes). This is essentially what the patPCA function shows for one color and it should show the main phenotypic variation that occurs along the axes. For multiple colors I agree it gets complicated and if you want, I can past some code into yours to create phenotypes for any PC values. I think that can help you explore the changes and loadings of the PC axes.
I think this should do the trick and give you the output of the prcomp command:
Out <- patPCA() comp <- Out[[3]] comp$x
Hope this helps,
Steven
From: weihanlau @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***<mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
Sent: Friday, 29 September 2023 07:55 To: StevenVB12/patternize @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***<mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
Cc: Steven M. Van Belleghem @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***<mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>; Comment @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***<mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue
42)
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740350098>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC456JFCDN4HKG5NXWS3X4ZPETANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***<mailto:***@***.******@***.***%3cmailto:***@***.******@***.***<mailto:***@***.******@***.***%3cmailto:***@***.******@***.***%3cmailto:***@***.******@***.***%3cmailto:***@***.******@***.***>>>>
— Reply to this email directly, view it on GitHub <
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740894483>,
or unsubscribe <
https://github.com/notifications/unsubscribe-auth/A32D7H4BKGL5BSFA5NE7ZGDX43D4JANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***<mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***<mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>
Secondary - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***<mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>
"It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742190690>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC446OIXUVYFW7EN5NMLX5HGGFANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***<mailto:***@***.******@***.***%3cmailto:***@***.******@***.***>>>
— Reply to this email directly, view it on GitHub < https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742193698>,
or unsubscribe < https://github.com/notifications/unsubscribe-auth/A32D7H44LR47UYJMSSJWNC3X5HHURANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***> Secondary - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742201147>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC44ZJDTDFYDEE7RM6I3X5HLDLANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***>>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742202416, or unsubscribe https://github.com/notifications/unsubscribe-auth/A32D7H6O4MK5XEMJGEMZWBLX5HLV5ANCNFSM6AAAAAA4HBYVXU . You are receiving this because you authored the thread.Message ID: @.<mailto:@.>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1742368891, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC4ZBMHVKBDTFGOAVM2DX5I3ZTANCNFSM6AAAAAA4HBYVXU. You are receiving this because you commented.Message ID: @.**@.>>
Hi Steven,
Thanks! It looks great! Is there a reason why the cartoon (though aligned) is cut off at a specific point. I was expecting a cartoon in the shape of the outline I put out, but I'm getting a cartoon that chops off half of the beetle's elytra (or half of the cartoon.):
[image: image.png]
Do you know if there's a way around this?
Best, Wei Han
On Tue, 3 Oct 2023 at 10:44, Steven M. Van Belleghem < @.***> wrote:
Hi Wei Han,
I think I resolved the issues.
For the PCA, the following needed to be added:
adjustCoords = T # also add this to the patLanRGB() function
landList = landmarkListRCESC
I added code that predicts phenotypes in the PCA. However, I noticed that it does not predict colors for areas that are invariable. Hance be careful with the interpretation (also for the predicted PCA changes). Alternatively, you could also map the original images in the PCA plot (like Hannah does here: https://hiweller.rbind.io/post/recolorize-patternize-workflow/).
It’s definitely fun to see your results. Does the PCA clustering relate to some geographic gradient?
Hope it works!
Steven
From: weihanlau @.> Sent: Monday, 2 October 2023 05:59 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
You were right! So sorry about that mix up! The groupings were great!
Wei Han
On Sun, 1 Oct 2023 at 15:12, Wei Han Lau @.<mailto:@.>> wrote:
Hmm let me look at that again (there's always a very high probability that I'm getting things wrong on my end)
Thanks!
Wei Han
On Sun, 1 Oct 2023 at 15:08, Steven M. Van Belleghem < @.<mailto:@.>> wrote:
Hi Wei Han,
Strange, Out[[2]] should be a table with the colors and label assignments and the rows in the same order as the samples in the PCA from prcomp$x. So that should allow you to easily produce a plot yourself.
I hope I can attend to your other issue soon!
Steven
From: weihanlau @.<mailto:@.>> Sent: Sunday, 1 October 2023 23:04 To: StevenVB12/patternize @.<mailto:@.>> Cc: Steven M. Van Belleghem @.<mailto:@.>>; Comment @.<mailto:@.>> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven!
Here's the associated code that produced that plot: https://github.com/weihanlau/Cicindela_final
Also, with Out[[2]], I get the loadings again with the associated ID's. What I was trying to get was the data frame that produced the prcomp to add a column to specify each specimen's population (defined earlier before patPCA), so I can visualize that on a regular autoplot. No matter though! I think I can figure this one out!
Thank you!
Wei Han
On Sun, 1 Oct 2023 at 14:34, Steven M. Van Belleghem < @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> wrote:
Hi Wei Han,
I hope this would do what you need:
Out <- patPCA() groupCol <- Out[[2]]
That object should be a table with the correct order of the labels.
I’m not sure what is causing the disparity. To make sure it’s not an issue with my code, could you share me what you got (script, landmarks, …)? I’ll also try adding the code for creating phenotypes.
Best,
Steven
From: weihanlau @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Sent: Sunday, 1 October 2023 22:22 To: StevenVB12/patternize @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Cc: Steven M. Van Belleghem @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>; Comment @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue
42)
Thank you Steven!
My plot looks lovely! Do you know how to maintain the groupings in the prcomp objected extracted from the patPCA function? The groupings (populations, in our case) are extrinsically defined before running the patPCA function, so they do not appear to be in the dataset.
Also, I've been fighting the outline and raster disparity all week in my patPCA function. Do you know if there's a fix to this? I have tried flipOutline and flipRaster to no avail.
[image: image.png] I would definitely love to have the code for the creation of phenotypes for any PC value! Thanks for that! Working with that might have to be something I explore down the line a little later on once I get over a current hump of work, though.
Best, Wei Han
On Fri, 29 Sept 2023 at 07:25, Steven M. Van Belleghem < @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
wrote:
Hi Wei Han,
Exciting to hear it’s working.
The best I can suggest at this point is indeed to recreate predicted phenotypes at the max and min values of a PC axis (and assuming a value of 0 for other PC axes). This is essentially what the patPCA function shows for one color and it should show the main phenotypic variation that occurs along the axes. For multiple colors I agree it gets complicated and if you want, I can past some code into yours to create phenotypes for any PC values. I think that can help you explore the changes and loadings of the PC axes.
I think this should do the trick and give you the output of the prcomp command:
Out <- patPCA() comp <- Out[[3]] comp$x
Hope this helps,
Steven
From: weihanlau @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
Sent: Friday, 29 September 2023 07:55 To: StevenVB12/patternize @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
Cc: Steven M. Van Belleghem @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>;
Comment
@.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue
42)
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740350098>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC456JFCDN4HKG5NXWS3X4ZPETANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.<mailto:@.**@.<mailto: @.**@.%3cmailto:@.**@.mailto:***@***.******@***.***%3cmailto:***@***.******@***.***%3cmailto:***@***.******@***.***%3cmailto:***@***.******@***.***>>>>
— Reply to this email directly, view it on GitHub <
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740894483>,
or unsubscribe <
https://github.com/notifications/unsubscribe-auth/A32D7H4BKGL5BSFA5NE7ZGDX43D4JANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>
Secondary - @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>
"It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742190690>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC446OIXUVYFW7EN5NMLX5HGGFANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***<mailto:***@***.******@***.***%3cmailto:***@***.******@***.***>>>
— Reply to this email directly, view it on GitHub <
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742193698>,
or unsubscribe <
https://github.com/notifications/unsubscribe-auth/A32D7H44LR47UYJMSSJWNC3X5HHURANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>
Secondary - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>
"It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742201147>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC44ZJDTDFYDEE7RM6I3X5HLDLANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***>>
— Reply to this email directly, view it on GitHub < https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742202416>,
or unsubscribe < https://github.com/notifications/unsubscribe-auth/A32D7H6O4MK5XEMJGEMZWBLX5HLV5ANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742368891>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC4ZBMHVKBDTFGOAVM2DX5I3ZTANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.>>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/42#issuecomment-1745355126, or unsubscribe https://github.com/notifications/unsubscribe-auth/A32D7H7USH36PQRVSBXBEBDX5Q6ILAVCNFSM6AAAAAA4HBYVXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBVGM2TKMJSGY . You are receiving this because you authored the thread.Message ID: @.***>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @. Secondary - @. "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
I can't see your image. Can you send it again?
Steven
-------- Original message -------- From: weihanlau @.> Date: 10/5/23 9:24 PM (GMT+01:00) To: StevenVB12/patternize @.> Cc: "Steven M. Van Belleghem" @.>, Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven,
Thanks! It looks great! Is there a reason why the cartoon (though aligned) is cut off at a specific point. I was expecting a cartoon in the shape of the outline I put out, but I'm getting a cartoon that chops off half of the beetle's elytra (or half of the cartoon.):
[image: image.png]
Do you know if there's a way around this?
Best, Wei Han
On Tue, 3 Oct 2023 at 10:44, Steven M. Van Belleghem < @.***> wrote:
Hi Wei Han,
I think I resolved the issues.
For the PCA, the following needed to be added:
adjustCoords = T # also add this to the patLanRGB() function
landList = landmarkListRCESC
I added code that predicts phenotypes in the PCA. However, I noticed that it does not predict colors for areas that are invariable. Hance be careful with the interpretation (also for the predicted PCA changes). Alternatively, you could also map the original images in the PCA plot (like Hannah does here: https://hiweller.rbind.io/post/recolorize-patternize-workflow/).
It’s definitely fun to see your results. Does the PCA clustering relate to some geographic gradient?
Hope it works!
Steven
From: weihanlau @.> Sent: Monday, 2 October 2023 05:59 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
You were right! So sorry about that mix up! The groupings were great!
Wei Han
On Sun, 1 Oct 2023 at 15:12, Wei Han Lau @.<mailto:@.>> wrote:
Hmm let me look at that again (there's always a very high probability that I'm getting things wrong on my end)
Thanks!
Wei Han
On Sun, 1 Oct 2023 at 15:08, Steven M. Van Belleghem < @.<mailto:@.>> wrote:
Hi Wei Han,
Strange, Out[[2]] should be a table with the colors and label assignments and the rows in the same order as the samples in the PCA from prcomp$x. So that should allow you to easily produce a plot yourself.
I hope I can attend to your other issue soon!
Steven
From: weihanlau @.<mailto:@.>> Sent: Sunday, 1 October 2023 23:04 To: StevenVB12/patternize @.<mailto:@.>> Cc: Steven M. Van Belleghem @.<mailto:@.>>; Comment @.<mailto:@.>> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven!
Here's the associated code that produced that plot: https://github.com/weihanlau/Cicindela_final
Also, with Out[[2]], I get the loadings again with the associated ID's. What I was trying to get was the data frame that produced the prcomp to add a column to specify each specimen's population (defined earlier before patPCA), so I can visualize that on a regular autoplot. No matter though! I think I can figure this one out!
Thank you!
Wei Han
On Sun, 1 Oct 2023 at 14:34, Steven M. Van Belleghem < @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>> wrote:
Hi Wei Han,
I hope this would do what you need:
Out <- patPCA() groupCol <- Out[[2]]
That object should be a table with the correct order of the labels.
I’m not sure what is causing the disparity. To make sure it’s not an issue with my code, could you share me what you got (script, landmarks, …)? I’ll also try adding the code for creating phenotypes.
Best,
Steven
From: weihanlau @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Sent: Sunday, 1 October 2023 22:22 To: StevenVB12/patternize @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Cc: Steven M. Van Belleghem @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>; Comment @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue
42)
Thank you Steven!
My plot looks lovely! Do you know how to maintain the groupings in the prcomp objected extracted from the patPCA function? The groupings (populations, in our case) are extrinsically defined before running the patPCA function, so they do not appear to be in the dataset.
Also, I've been fighting the outline and raster disparity all week in my patPCA function. Do you know if there's a fix to this? I have tried flipOutline and flipRaster to no avail.
[image: image.png] I would definitely love to have the code for the creation of phenotypes for any PC value! Thanks for that! Working with that might have to be something I explore down the line a little later on once I get over a current hump of work, though.
Best, Wei Han
On Fri, 29 Sept 2023 at 07:25, Steven M. Van Belleghem < @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
wrote:
Hi Wei Han,
Exciting to hear it’s working.
The best I can suggest at this point is indeed to recreate predicted phenotypes at the max and min values of a PC axis (and assuming a value of 0 for other PC axes). This is essentially what the patPCA function shows for one color and it should show the main phenotypic variation that occurs along the axes. For multiple colors I agree it gets complicated and if you want, I can past some code into yours to create phenotypes for any PC values. I think that can help you explore the changes and loadings of the PC axes.
I think this should do the trick and give you the output of the prcomp command:
Out <- patPCA() comp <- Out[[3]] comp$x
Hope this helps,
Steven
From: weihanlau @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
Sent: Friday, 29 September 2023 07:55 To: StevenVB12/patternize @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
Cc: Steven M. Van Belleghem @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>;
Comment
@.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue
42)
Hi Steven,
I’m so sorry for my lengthy period of silence! The past few weeks hit me like a truck, with TAship responsibilities ramping up and everything getting busy on campus. Everything is working well with my efforts to work with patternize and recolorize to quantify elytral variation in the beetles I’m studying. Thank you so much for your help! I couldn’t have made it work without your help.
I just have a few final basic questions about running principal component analyses with patternize:
Running a PCA in most of my work is usually done as an initial step to visualize the distribution of variation in my data. What I typically end up doing once any discernible groupings can be observed in a PC plot is to first run a scree plot or some sort of summary function to see how much variation is captured by each principal component. After which, I take a look at the PC loadings to see which of the data variables are related to the principal components. With a patternize principal component plot, looking at the percentage of variation captured by each PC component is simple enough. However, looking at variables associated with each PC component is a little difficult for interpretation purposes, given the way the image rasters are transformed for PCA analysis.
Are there any recommended ways to present summary statistics to make some sense of the PC components with patternize PCA plots? Or should any initial observations of the data be restricted to what can be inferred from the generated explanatory heat map figures (e.g. noting where the variation is captured on the specified areas on the image and how the patterns observed in the data can be described by this)?
Also, I understand that the patPCA function returns a prcomp object, but I can’t seem to isolate the PCA plot itself (without the heat maps) to perform manipulations on it with other packages (e.g. running autoplot() on the prcomp object to customize the PC plot). I'm running into some class conversion issues where the patPCA seems to be outputting a list. Is there a way to do this?
Thanks so much!
Best, Wei Han
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740350098>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC456JFCDN4HKG5NXWS3X4ZPETANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.<mailto:@.**@.<mailto: @.**@.%3cmailto:@.**@.mailto:***@***.******@***.***%3cmailto:***@***.******@***.***%3cmailto:***@***.******@***.***%3cmailto:***@***.******@***.***>>>>
— Reply to this email directly, view it on GitHub <
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1740894483>,
or unsubscribe <
https://github.com/notifications/unsubscribe-auth/A32D7H4BKGL5BSFA5NE7ZGDX43D4JANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>
Secondary - @.<mailto:@.<mailto: @.%3cmailto:@.mailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***%3cmailto:***@***.***>>
"It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742190690>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC446OIXUVYFW7EN5NMLX5HGGFANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***<mailto:***@***.******@***.***%3cmailto:***@***.******@***.***>>>
— Reply to this email directly, view it on GitHub <
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742193698>,
or unsubscribe <
https://github.com/notifications/unsubscribe-auth/A32D7H44LR47UYJMSSJWNC3X5HHURANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>
Secondary - @.<mailto:@.mailto:***@***.***%3cmailto:***@***.***>
"It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub<
https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742201147>,
or unsubscribe<
https://github.com/notifications/unsubscribe-auth/ABQOC44ZJDTDFYDEE7RM6I3X5HLDLANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.mailto:***@***.******@***.***>>
— Reply to this email directly, view it on GitHub < https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742202416>,
or unsubscribe < https://github.com/notifications/unsubscribe-auth/A32D7H6O4MK5XEMJGEMZWBLX5HLV5ANCNFSM6AAAAAA4HBYVXU>
. You are receiving this because you authored the thread.Message ID: @.<mailto:@.>>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
--
Wei Han - Homeschooler and Arsenal Fan
Main - @.<mailto:@.> Secondary - @.<mailto:@.> "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/42#issuecomment-1742368891>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC4ZBMHVKBDTFGOAVM2DX5I3ZTANCNFSM6AAAAAA4HBYVXU>.
You are receiving this because you commented.Message ID: @.**@.>>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/42#issuecomment-1745355126, or unsubscribe https://github.com/notifications/unsubscribe-auth/A32D7H7USH36PQRVSBXBEBDX5Q6ILAVCNFSM6AAAAAA4HBYVXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBVGM2TKMJSGY . You are receiving this because you authored the thread.Message ID: @.***>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @. Secondary - @. "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1749511543, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC433ZOTRKA7CXWKE52LX54COXAVCNFSM6AAAAAA4HBYVXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBZGUYTCNJUGM. You are receiving this because you commented.Message ID: @.***>
Does it work now?
Hmm. That's not an issue I had. Can you try to replot an make your plotting area larger?
Steven
-------- Original message -------- From: weihanlau @.> Date: 10/5/23 9:29 PM (GMT+01:00) To: StevenVB12/patternize @.> Cc: "Steven M. Van Belleghem" @.>, Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Does it work now?
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1749520087, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC46DNT6EI22QWN2NR3DX54DBHAVCNFSM6AAAAAA4HBYVXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBZGUZDAMBYG4. You are receiving this because you commented.Message ID: @.***>
Yup, I tried to crop a larger area but nothing is changing thus far. Let me try to re-run everything and hope this goes away. Sorry for the bother!
On Thu, 5 Oct 2023 at 13:30, Steven M. Van Belleghem < @.***> wrote:
Hmm. That's not an issue I had. Can you try to replot an make your plotting area larger?
Steven
-------- Original message -------- From: weihanlau @.> Date: 10/5/23 9:29 PM (GMT+01:00) To: StevenVB12/patternize @.> Cc: "Steven M. Van Belleghem" @.>, Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Does it work now?
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/42#issuecomment-1749520087>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC46DNT6EI22QWN2NR3DX54DBHAVCNFSM6AAAAAA4HBYVXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBZGUZDAMBYG4>.
You are receiving this because you commented.Message ID: @.***>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/42#issuecomment-1749522039, or unsubscribe https://github.com/notifications/unsubscribe-auth/A32D7H2IWDYFUIS2645AUBLX54DGTAVCNFSM6AAAAAA4HBYVXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBZGUZDEMBTHE . You are receiving this because you authored the thread.Message ID: @.***>
--
Wei Han - Homeschooler and Arsenal Fan
Main - @. Secondary - @. "It is vain for you to rise up early, to sit up late, to eat the bread of sorrows: for so he giveth his beloved sleep."(Psalm 127:2)
Please consider the environment before printing this email
Hi Steven,
I'm really, really sorry, but this isn't working. It seems like the cartoon is scaled correctly (I can see a corner of it if I don't adjust coordinates in the PCA function), but somehow the heatmap itself is bigger than the cartoon, causing a cutoff at the top of the cartoon and the heatmap and a mismatch when they are overlapping. I'm thinking it's something to do with a disjunction betweeen the landmarks of my .jpgs and the cartoon outline. But that's really strange because they were generated from the same image. There also seems to be some inconsistencies in how patlanRGB reads landmarks. Sometimes, when I run the funciton with a cropOffset of c(200, 200, 200, 200), the the "black and white" pattern map shows the full elytra of the beetle, but sometimes it cuts it off a little to the right.
There also seems to be a correlation between the comparison image shown in the patlanRGB function and the cartoon alignment in the patPCA function. The bigger the "black and white" pattern map appears in the comparison picture, the bigger the heatmap shows in the patPCA cartoon.
I then tried again to rerun everything again and got something that looked like this! It looks really cool! but clearly something is amiss.
Wei Han
Hi Wei Han,
I’m unable to reproduce your problem.
@.***
You seem to have some extra point appearing much higher on PC2. I wonder if it would help to make sure you start running the code from scratch with an empty environment.
Steven
From: weihanlau @.> Sent: Friday, 6 October 2023 03:27 To: StevenVB12/patternize @.> Cc: Steven M. Van Belleghem @.>; Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hi Steven,
I'm really, really sorry, but this isn't working. It seems like the cartoon is scaled correctly (I can see a corner of it if I don't adjust coordinates in the PCA function), but somehow the heatmap itself is bigger than the cartoon, causing a cutoff at the top of the cartoon and the heatmap and a mismatch when they are overlapping. I'm thinking it's something to do with a disjunction betweeen the landmarks of my .jpgs and the cartoon outline. But that's really strange because they were generated from the same image. There also seems to be some inconsistencies in how patlanRGB reads landmarks. Sometimes, when I run the funciton with a cropOffset of c(200, 200, 200, 200), the the "black and white" pattern map shows the full elytra of the beetle, but sometimes it cuts it off a little to the right.
There also seems to be a correlation between the comparison image shown in the patlanRGB function and the cartoon alignment in the patPCA function. The bigger the "black and white" pattern map appears in the comparison picture, the bigger the heatmap shows in the patPCA cartoon.
I then tried again to rerun everything again and got something that looked like this! It looks really cool! but clearly something is amiss.
Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1749865191, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC43PICWX6JRMFEEJIALX55M53AVCNFSM6AAAAAA4HBYVXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBZHA3DKMJZGE. You are receiving this because you commented.Message ID: @.**@.>>
Hello Steven!
I'm so very sorry for my radio silence again! Thank you so much for your help, things worked beautifully in the end. I went back through this thread and realized that I forgot to reply to some of your questions. Sorry about that! Yes, the gradients do reflect a really neat latitudinal geographical gradient. Those results show that the pale maculation patterns do seem to decrease towards the East Coast, which is something that we've known about these beetles already, but it's certainly really cool to see this trend captured by patternize and to have some numbers back up what has long since been qualitative observations! I'm not really sure if there's a biological reason behind this pattern, but it's certainly something interesting that I'm hoping to look into.
I'm definitely going to revisit patternize as a tool in my future analyses. Clearly, patternize is great for capturing these really stark colour patterns, but I'm going to try and capture the variation in the colours that make up the composition of these patterns too (as opposed to making a universal template and reimposing the colours back on to the beetles). This variation (light brown, dark brown, green-ish brown) is a lot more nuanced, so it'll definitely be a little more challenging.
Thanks for everything!
Best, Wei Han
Thanks for letting me know Wei Han. I look forward reading more about it ;)
Good luck with the further endeavors!
Steven
-------- Original message -------- From: weihanlau @.> Date: 11/8/23 9:22 PM (GMT+01:00) To: StevenVB12/patternize @.> Cc: "Steven M. Van Belleghem" @.>, Comment @.> Subject: Re: [StevenVB12/patternize] Problem with patLanRGB (Issue #42)
Hello Steven!
I'm so very sorry for my radio silence again! Thank you so much for your help, things worked beautifully in the end. I went back through this thread and realized that I forgot to reply to some of your questions. Sorry about that! Yes, the gradients do reflect a really neat latitudinal geographical gradient. Those results show that the pale maculation patterns do seem to decrease towards the East Coast, which is something that we've known about these beetles already, but it's certainly really cool to see this trend captured by patternize and to have some numbers back up what has long since been qualitative observations! I'm not really sure if there's a biological reason behind this pattern, but it's certainly something interesting that I'm hoping to look into.
I'm definitely going to revisit patternize as a tool in my future analyses. Clearly, patternize is great for capturing these really stark colour patterns, but I'm going to try and capture the variation in the colours that make up the composition of these patterns too (as opposed to making a universal template and reimposing the colours back on to the beetles). This variation (light brown, dark brown, green-ish brown) is a lot more nuanced, so it'll definitely be a little more challenging.
Thanks for everything!
Best, Wei Han
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/42#issuecomment-1802594680, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC4Y2SAVBHYMH3Q23I43YDPSX7AVCNFSM6AAAAAA4HBYVXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBSGU4TINRYGA. You are receiving this because you commented.Message ID: @.***>
Dear Steven,
I've been trying to use the function patLanRGB() in the patternize package to extract a colour pattern from some beetle specimens. I'm running into some problems, though. Every time I run the patLanRGB() function, I get several warning messages that reads: "Warning: [rast] unknown extent", and the resulting pattern that gets plotted looks really strange (like a bunch of dots in a neat row, which is not what I was expecting at all).
Here's are some plots that were returned from the following code. It's clearly picking up the RGB values from the light brown parts, but I don't understand why it looks like this.
patlanRGB <- patLanRGB(samplejpg, landmarkListRGB, RGB, colOffset = 0.05, transformRef = landmarkListRGB[[1]], resampleFactor = 1, adjustCoords = T, plot = "compare")
For reference, attached below is a picture of one of the images that I'm trying to extract the colour pattern from. I'm also not really sure why patLanRGB() spits out a "cropped" rectangular portion of each image (see above).
Would you happen to know why all of this is happening?
My pictures are all jpgs. Prior to this, I ran the images that I'm using through the package recolorize to impose a standard colour palette of two colours on to them (hence, them looking quite pixelated). The RGB values that I'm using are the RGB values from the light brown area of the specimen, which should be the same for all of the images, since I imposed a colour palette with recolorize on all of my images.
Thank you so much for any help at all!
Wei Han