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

Is it made only for example files. #4

Open olferievm opened 1 year ago

olferievm commented 1 year ago

Hi Keniajin,

The way the R script is written it can work only with the example files. Do you plan to make it work for everyone?

Keniajin commented 1 year ago

Hi @olferievm , which quantification software of estimating pixel intensities are you using. If you are using Proscanarray Express software (PerkinElmer) , QuantArray software (GSI Lumonics) or GenePix Pro software (Molecular Devices) generate data with similar parameters that can be used with protGear . If you can share the parameters in your data file this can be useful.

olferievm commented 1 year ago

I have light intensities generated by GenePix Pro 7.3 software. It is not my data and I can't share them. But here are column names from the gpr file.

"Block" "Column"    "Row"   "Name"  "ID"    "X" "Y" "Dia."  "F532 Median"   "F532 Mean" "F532 SD"   "F532 CV"   "B532"  "B532 Median"   "B532 Mean" "B532 SD"   "B532 CV"   "% > B532+1SD"  "% > B532+2SD"  "F532 % Sat."   "Ratio of Medians (532/635)"    "Ratio of Means (532/635)"  "Median of Ratios (532/635)"    "Mean of Ratios (532/635)"  "Ratios SD (532/635)"   "Rgn Ratio (532/635)"   "Rgn R2 (532/635)"  "F Pixels"  "B Pixels"  "Circularity"   "Sum of Medians (532/635)"  "Sum of Means (532/635)"    "Log Ratio (532/635)"   "F532 Median - B532"    "F532 Mean - B532"  "F532 Total Intensity"  "SNR 532"   "Flags" "Normalize" "Autoflag"
1   1   1   "AB1"   "AB1"   3770    1160    170 1911    1936    612 31  430 430 436 35  8   100 100 0   100000.000  100000.000  0.000   0.000   0.000   0.000   0.000   208 1654    100 1481    1506    16.610  1481    1506    402740  42.857  0   0   0

For example for function visualize_slide you have a fixed parameter F635 Median. I need to visualize F532 Median. I got problems with other functions like: plot_bg, matrix_normalize, extract_bg, etc... Obviously, I tried to fix them, but then give up.

Here is my version of visualize_slide function. You can use it and modify the code as you like. At least it works in my example. It works only for my files, but I assume it might works for other formats as well. Sorry no annotation here.

visualize_slide <- function(infile, MFI_var, d_f = NA, ncol = 2, interactive = TRUE, height = 400, width = 400, pointsize = 2, margin = NULL, names = NULL){

  require(cowplot)
  require(ggplot)
  require(ggplotly)
  require(dplyr)

  if (is.na(d_f)) {
    d_f <- read_array_visualize(infile)
  }

  N = length(unique(d_f$Block))
  nrow = ceiling(N/ncol)

  fig.height = height * nrow
  fig.width = width * ncol

  if(is.null(names)){names = sprintf("Block %s",1:N)}
  if(length(names) != N){stop("names is a character vector with length equal number of blocks")}

# Not sure if I need it?
#  if(is.null(margin)) margin = c(0,0,0,0)

  d_f <- d_f %>%
    dplyr::mutate(
      Block = factor(Block,
                     levels=unique(Block),
                     labels=names)) 

  # Keep the same name ...
  d_f <- d_f %>%
    dplyr::mutate(., across(all_of(MFI_var),.fns=log2,.names="logMFI"))

  # 
  g <- ggplot(d_f, aes(x = X, y = Y, color = logMFI, text = paste(Name,"<br> MFI:", round(2^logMFI,0))))
  g <- g + geom_point(size = pointsize)
  g <- g + scale_color_distiller(palette = "YlOrRd", direction = 1)
  g <- g + scale_y_reverse() + theme(legend.position = "none")
  g <- g + facet_wrap(~Block, scales = "free", ncol = ncol)

  if(interactive){
    ggplotly(g,
             height = fig.height,
             width =fig.width)
  }else{
    g
  }
}
Keniajin commented 1 year ago

In the example of the visualize_slide() function as shown below `

' visualize_slide(

' infile = system.file("extdata", "/array_data/machine1/KK2-06.txt",

' package="protGear"),

' MFI_var = "B635 Median"

' )`

You can specify the exact name of the parameter you want to visualize. In your case the MFI_var will be F532 Median .

For the other functions, you have to specify the parameters to use while doing the processing.