Keniajin / protGear

protGear is a package for protein microarray data processing just before the main analysis.
https://keniajin.github.io/protGear/
1 stars 1 forks source link

Bug and final error. #1

Open JosephLongworth opened 2 years ago

JosephLongworth commented 2 years ago

Hi

Thank you for the interesting software. First, can I apologize I'm new to the interaction on GitHub usually working on my own code so the correct format to comment is not something I'm aware of yet.

I'm trying to implement Protgrear to analyze some data but have found compatibility issues with our *.gpr files from a genepix machine.

In addition, I have a request as to if the shiny has a download function for the normalized output. as though it is referred to i don't see where to download such at least in my implementation.

The slide visualization I found would not work unless I implemented the following alternative code for functions visualize_slide and visualize_slide_2d.

JPL_visualize_slide=function(MFI_var,interactive,d_f){
    d_f <- d_f %>% group_by(Block) %>%
      mutate(meanX = mean(X), 
                                              meanY = mean(Y),
                                              maxY = max(Y),
                                              maxX = max(X),
                                              minY = min(Y), 
                                              minX = min(X))
  MFI_var_sys <- rlang::sym(MFI_var)
  mid <- median(log(d_f[[MFI_var]]))
  labels <- sprintf("<b>%s</b><br> MFI= %s ", d_f$Name, formatC(d_f[[MFI_var]], 
                                                                format = "d", big.mark = ",")) %>% lapply(htmltools::HTML)
  point_size <- 0.5
  if (interactive == FALSE) 
    point_size <- 1
  p <- ggplot(d_f, aes(x = X, y = -Y, text = labels)) +
    geom_point(size = point_size, aes_string(colour = sprintf("log(`%s`)", MFI_var)))  +
    theme_void() +
    theme(legend.position = "none") +
    scale_color_gradient2(midpoint = mid, low = "blue",
                          mid = "white", high = "red", space = "Lab") + 
    geom_text(aes(x = meanX, y = -meanY, label = paste("Block", 
                                                     Block)), color = "black", size = 2)

  if (interactive == FALSE) {
    return(p)
  }
  else if (interactive == TRUE) {
    p <- ggplotly(p, tooltip = "text")
    return(p)
  }

}
JPL_visualize_slide_2d=function (MFI_var, d_f = NA) 
{
    d_f <- d_f %>% group_by(Block) %>% mutate(meanX = mean(X), 
                                              meanY = mean(Y), maxY = max(Y), maxX = max(X), minY = min(Y), 
                                              minX = min(X))

  mid <- median(log(d_f[[MFI_var]]))
  ggplot(data = d_f, aes_string(x = "X", y = sprintf("-%s", 
                                                     "Y"), z = sprintf("log(`%s`)", MFI_var))) + stat_summary_2d(fun = median) + 
    scale_fill_gradient2(midpoint = mid, low = "blue", mid = "white", 
                         high = "red", space = "Lab") + theme_void() + theme(legend.position = "none") + 
    geom_text(aes(x = meanX, y = -meanY, label = paste("Block", 
                                                       Block)), color = "black", size = 4)
}
Keniajin commented 2 years ago

Hi @JosephLongworth could you share a sample of the `gpr and the error thrown after trying the tool.