Last updated: 2017-12-01

Code version: df49739

Load packages and data

library(knitr)

Load nuclei detection results directly from image analysis output /project2/gilad/fucci-seq/intensities. The results are made into a summary table.

plate: labeled by the mix of individual cell lines
image: labels assigned by the JULI imaging system. These will be converted to correspond to C1 plate labels (rows and columns).
nnuclei: number of nuclei detected in a single cell sample

fls <- list.files("/project2/gilad/fucci-seq/intensities", pattern = "rds", full.names = TRUE)

nuclei_table <- do.call(rbind, lapply(1:length(fls), function(index) {
  tmp <- readRDS(fls[[index]])
  plate <- strsplit(strsplit(fls[index], split="/")[[1]][[6]], 
                    split=".", fixed = TRUE)[[1]][[1]]
  data.frame(plate=plate, nnuclei=tmp, image=names(tmp))
}))

saveRDS(nuclei_table, "/project2/gilad/joycehsiao/fucci-seq/output/image-qc.rds")

Inspect samples

nuclei_table <- readRDS("/project2/gilad/joycehsiao/fucci-seq/output/image-qc.rds")
kable(nuclei_table[which(nuclei_table$nnuclei==0|is.na(nuclei_table$nnuclei)),])
plate nnuclei image
00010 18511_18855 NA 00010
00048 18511_18855 NA 00048
000071 18855_19098 NA 00007
000481 18855_19098 NA 00048
000712 18855_19101 NA 00071
000882 18855_19101 NA 00088
000463 18855_19160 NA 00046
000164 18870_18511 0 00016
000314 18870_18511 NA 00031
000324 18870_18511 NA 00032
000604 18870_18511 NA 00060
000684 18870_18511 NA 00068
000844 18870_18511 NA 00084
000165 18870_18855 NA 00016
000785 18870_18855 NA 00078
000096 18870_19101 NA 00009
000666 18870_19101 NA 00066
000756 18870_19101 NA 00075
000177 18870_19160 NA 00017
000529 19098_18870 NA 00052
0000710 19098_19160 NA 00007
0002010 19098_19160 NA 00020
0002610 19098_19160 NA 00026
0004910 19098_19160 NA 00049
0008410 19098_19160 0 00084
0004211 19101_18511 NA 00042
0005411 19101_18511 NA 00054
0005611 19101_18511 NA 00056
0001613 19101_19160 NA 00016
0002513 19101_19160 NA 00025
0002613 19101_19160 NA 00026
0002813 19101_19160 NA 00028
0003313 19101_19160 NA 00033
0003015 19160_18870 0 00030
0003215 19160_18870 0 00032

Printing images for inspection

This section is for record keeping. All images for samples with no nucleus detected have been converted to PNG format and stored in /project2/gilad/fucci-seq/images-inspect-zero-nucleus.

The code below will save images in png format at /project2/gilad/fucci-seq/images-inspect-zero-nucleus.

#' @param wells vector of wells ID (use the format specified above).
#' @param plate plate ID

print_png <- function(plate, wells) {
  for (index in 1:length(wells)) {
    id <- wells[index]
    dir_images_data_pl <- paste0("/project2/gilad/fucci-seq/images_curated/",plate,"/")
    dir_output <- "/project2/gilad/fucci-seq/images-inspect-zero-nucleus/"
    bright <- readImage(paste0(dir_images_data_pl, "BRIGHT/", id, ".TIFF"))
    dapi <- readImage(paste0(dir_images_data_pl, "DAPI/", id, ".TIFF"))
    gfp <- readImage(paste0(dir_images_data_pl, "GFP/", id, ".TIFF"))
    rfp <- readImage(paste0(dir_images_data_pl, "RFP/", id, ".TIFF"))
    
    writeImage(bright, paste0(dir_output, plate,".",id,".bright.png"))
    writeImage(dapi, paste0(dir_output, plate,".",id,".dapi.png"))
    writeImage(gfp, paste0(dir_output, plate,".",id,".gfp.png"))
    writeImage(rfp, paste0(dir_output, plate,".",id,".rfp.png"))
    # combo <- combine(dapi, bright, gfp, rfp)
    # writeImage(combo, paste0(dir_output, plate,".",id,".combo.png"))
  }
}


tmp_table <- nuclei_table[which(nuclei_table$nnuclei == 0 | is.na(nuclei_table$nnuclei)),]
plates <- unique(as.character(tmp_table$plate))
for (index in 1:length(plates)) {
  plate <- plates[index]
  cases <- nuclei_table[which( (nuclei_table$nnuclei == 0 | is.na(nuclei_table$nnuclei)) & nuclei_table$plate == plate),]
  wells <- as.character(cases$image)
  print_png(plate, wells) 
}

Session information

sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Scientific Linux 7.2 (Nitrogen)

Matrix products: default
BLAS: /home/joycehsiao/miniconda3/envs/fucci-seq/lib/R/lib/libRblas.so
LAPACK: /home/joycehsiao/miniconda3/envs/fucci-seq/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] knitr_1.16

loaded via a namespace (and not attached):
 [1] compiler_3.4.1  backports_1.0.5 magrittr_1.5    rprojroot_1.2  
 [5] tools_3.4.1     htmltools_0.3.6 yaml_2.1.14     Rcpp_0.12.13   
 [9] stringi_1.1.2   rmarkdown_1.6   highr_0.6       git2r_0.19.0   
[13] stringr_1.2.0   digest_0.6.12   evaluate_0.10.1

This R Markdown site was created with workflowr