Using synapsis

 packages = c("rmarkdown","BiocManager","imager")

 package.check <- lapply(
  packages,
   FUN = function(x) {
     if (!require(x, character.only = TRUE)) {
       install.packages(x, dependencies = TRUE)
       library(x, character.only = TRUE)
     }
   }
 )
## Loading required package: rmarkdown
## Loading required package: BiocManager
## Loading required package: imager
## Loading required package: magrittr
## 
## Attaching package: 'imager'
## The following object is masked from 'package:magrittr':
## 
##     add
## The following objects are masked from 'package:stats':
## 
##     convolve, spectrum
## The following object is masked from 'package:graphics':
## 
##     frame
## The following object is masked from 'package:base':
## 
##     save.image
library(knitr)
library(rmarkdown)
#BiocManager::install("EBImage")
library(EBImage)
## 
## Attaching package: 'EBImage'
## The following objects are masked from 'package:imager':
## 
##     channel, dilate, display, erode, resize, watershed
library(ggplot2)
 
## comment out if you have crops..

#path = "~/Documents/svi/imaging/data-folder/test-folder/all-KO"
#files <- list.files(path)
#setwd("~/Documents/synapsis/synapsis/R")
#source("auto_crop.R")
# call routine to crop images, and display their "cell number"
#crop(files, path, "regular")


#### make sure that these are output in a new folder.

### call the next functions on the new folder.

# call get_pachytene()
#path = "~/Documents/svi/imaging/data-folder/test-folder/all-KO/crops"
#source("~/Documents/synapsis/synapsis/R/get_pachytene.R")
#files <- list.files(path)
#get_pachytene(files,path)

### only keep BW filter

# call count_foci() on the pachytene files only.

path = "~/Documents/svi/imaging/data-folder/test-folder/all-KO/crops/pachytene"
source("~/Documents/synapsis/synapsis/R/count_foci.R")
files <- list.files(path)
foci_counts <- count_foci(files,path)
## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] "cell counter is"
## [1] 0

## [1] 25.11364
## [1] 28
## [1] 10.42184
column_2 <- as.data.frame(foci_counts)
write.csv(column_2, "temp.csv",row.names = FALSE)

# Call for KO folder, call for WT folder.

# call same routine, but excluding those which are cropped badly.