Commit 2f82501b authored by Lucy McNeill's avatar Lucy McNeill
Browse files

replace instaces of file with img_file in measure_distances

parent 41b55ee3
......@@ -43,20 +43,20 @@ measure_distances <- function(img_path,offset_px = 0.2, offset_factor = 3, brush
df_lengths <- data.frame(matrix(ncol = length(df_cols), nrow = 0))
#colnames(df_lengths) <- df_cols
## for each image that is *-dna.jpeg,
for (file in file_list){
filename_path_test = paste0(img_path,"/crops/",stage,"/", file)
file = filename_path_test
if(grepl(paste0('*',channel2_string,'.',file_ext,'$'), file)){
for (img_file in file_list){
filename_path_test = paste0(img_path,"/crops/",stage,"/", img_file)
img_file = filename_path_test
if(grepl(paste0('*',channel2_string,'.',file_ext,'$'), img_file)){
#if(grepl("*SYCP3.jpeg", file)){
file_dna = file
file_dna = img_file
image_count <- image_count +1
image <- readImage(file_dna)
img_orig <- channel(2*image, "grey")
antibody1_store <- 1
}
if(grepl(paste0('*',channel1_string,'.',file_ext,'$'), file)){
if(grepl(paste0('*',channel1_string,'.',file_ext,'$'), img_file)){
#if(grepl("*MLH3.jpeg", file)){
file_foci = file
file_foci = img_file
image <- readImage(file_foci)
img_orig_foci <- channel(image, "gray")
# call functions: get
......@@ -123,7 +123,7 @@ measure_distances <- function(img_path,offset_px = 0.2, offset_factor = 3, brush
print(cell_count)
}
################ distance starts (make function later)
dimensionless_dist <- get_distance(strands,num_strands,new_img,foci_label, foci_count_strand, strand_iter,file,annotation,eccentricity_min, max_strand_area,cell_count,KO_str ,WT_str,KO_out, WT_out)
dimensionless_dist <- get_distance(strands,num_strands,new_img,foci_label, foci_count_strand, strand_iter,img_file,annotation,eccentricity_min, max_strand_area,cell_count,KO_str ,WT_str,KO_out, WT_out)
#colnames(dimensionless_dist) <- df_cols
df_lengths <- rbind(df_lengths, dimensionless_dist)
}
......@@ -199,7 +199,7 @@ threshold_foci_crop <- function(image, offset_factor, brush_size, brush_sigma,st
#' @param foci_label, A black white mask with foci as objects
#' @param foci_count_strand, Number of foci counted located on the one SC
#' @param strand_iter, Strand number in iteration over all in cell
#' @param file, original filename that cell candidate came from. Used to identify e.g. genotype for data frame.
#' @param img_file, original filename that cell candidate came from. Used to identify e.g. genotype for data frame.
#' @param annotation, Choice to output pipeline choices (recommended to knit)
#' @param eccentricity_min, The minimum eccentricity (from computefeatures) of a strand to proceed with measuring
#' @param max_strand_area, Maximum pixel area of a strand
......@@ -210,7 +210,7 @@ threshold_foci_crop <- function(image, offset_factor, brush_size, brush_sigma,st
#' @param WT_out string in output csv in genotype column, for knockout. Defaults to +/+.
#' @return Data frame with properties of synaptonemal (SC) measurements
#'
get_distance <- function(strands,num_strands,new_img,foci_label, foci_count_strand, strand_iter,file,annotation, eccentricity_min, max_strand_area,cell_count,KO_str ,WT_str,KO_out, WT_out){
get_distance <- function(strands,num_strands,new_img,foci_label, foci_count_strand, strand_iter,img_file,annotation, eccentricity_min, max_strand_area,cell_count,KO_str ,WT_str,KO_out, WT_out){
tryCatch({
no_strands <- nrow(num_strands)
strand_count<- 0
......@@ -332,7 +332,7 @@ get_distance <- function(strands,num_strands,new_img,foci_label, foci_count_stra
### call measure distance between 2
dimensionless_dist <- get_distance_between_two(distance_strand,distance_strand_2,per_strand,foci_label, walkers, noise_gone,start_x,start_y,start_x2,start_y2,start_dir,cx,cy,mean_x,mean_y,strand_count,file,annotation,cell_count,strand_iter,KO_str ,WT_str,KO_out, WT_out)
dimensionless_dist <- get_distance_between_two(distance_strand,distance_strand_2,per_strand,foci_label, walkers, noise_gone,start_x,start_y,start_x2,start_y2,start_dir,cx,cy,mean_x,mean_y,strand_count,img_file,annotation,cell_count,strand_iter,KO_str ,WT_str,KO_out, WT_out)
return(dimensionless_dist)
##### ends here
### you've got a single strand here. try and count distance between foci.
......@@ -347,11 +347,11 @@ get_distance <- function(strands,num_strands,new_img,foci_label, foci_count_stra
error = function(e) {
#what should be done in case of exception?
str(e) # #prints structure of exception
if(grepl( WT_str, file, fixed = TRUE) == TRUE){
if(grepl( WT_str, img_file, fixed = TRUE) == TRUE){
genotype <- WT_out
}
if(grepl( KO_str, file, fixed = TRUE) == TRUE){
if(grepl( KO_str, img_file, fixed = TRUE) == TRUE){
genotype <- KO_out
}
#dimensionless_dist_major_fail <- c(file, genotype, "NA", "NA", "NA", "fail")
......@@ -1145,7 +1145,7 @@ get_next_second_dir <- function(new_square_2,ix2,iy2,dir_2,window,chosen_dir,dis
#' @param mean_x, starting point x that the two branches move away from to trace out the SC (annotation purposes only)
#' @param mean_y, starting point x that the two branches move away from to trace out the SC (annotation purposes only)
#' @param strand_iter, Strand number in iteration over all in cell
#' @param file, original filename that cell candidate came from. Used to identify e.g. genotype for data frame.
#' @param img_file, original filename that cell candidate came from. Used to identify e.g. genotype for data frame.
#' @param annotation, Choice to output pipeline choices (recommended to knit)
#' @param cell_count Unique cell number
#' @param uid_strand Unique strand number
......@@ -1155,7 +1155,7 @@ get_next_second_dir <- function(new_square_2,ix2,iy2,dir_2,window,chosen_dir,dis
#' @param WT_out string in output csv in genotype column, for knockout. Defaults to +/+.
#' @return List of fractional distances between foci for all SCs with two. Optional: total distances of SCs. Optional: images of all resulting traces/ foci locations.
#'
get_distance_between_two <- function(distance_strand,distance_strand_2,per_strand,foci_label, walkers, noise_gone,start_x,start_y,start_x2,start_y2,start_dir,cx,cy,mean_x,mean_y,strand_iter,file,annotation,cell_count, uid_strand,KO_str ,WT_str,KO_out, WT_out){
get_distance_between_two <- function(distance_strand,distance_strand_2,per_strand,foci_label, walkers, noise_gone,start_x,start_y,start_x2,start_y2,start_dir,cx,cy,mean_x,mean_y,strand_iter,img_file,annotation,cell_count, uid_strand,KO_str ,WT_str,KO_out, WT_out){
strand_info <- computeFeatures.moment(bwlabel(per_strand),as.matrix(foci_label))
strand_info <- as.data.frame(strand_info)
foci_1_x <- strand_info$m.cx[1]
......@@ -1613,11 +1613,11 @@ get_distance_between_two <- function(distance_strand,distance_strand_2,per_stran
if(distance_f1 < 10){
if(distance_f2 < 10){
#dimensionless_dist <- append(dimensionless_dist,px_length)
if(grepl( WT_str, file, fixed = TRUE) == TRUE){
if(grepl( WT_str, img_file, fixed = TRUE) == TRUE){
genotype <- WT_out
}
if(grepl( KO_str, file, fixed = TRUE) == TRUE){
if(grepl( KO_str, img_file, fixed = TRUE) == TRUE){
genotype <- KO_out
}
uid <- strand_iter
......@@ -1626,8 +1626,8 @@ get_distance_between_two <- function(distance_strand,distance_strand_2,per_stran
# df_cols <- c("file","genotype","foci_no","foci_per_strand", "total_SC_length","total_pixel_distance","foci_location_along", "fractional_distance_between_two", "pass_fail", "foci_location_x", "foci_location_y", "foci_location_x_line", "foci_location_y_line")
dimensionless_dist_pass_f1 <- c(file,cell_count, genotype,1,2, uid,uid_strand,(distance_strand+ distance_strand_2), px_length,foci_location_along_1, dim_length,"pass", foci_1_x, foci_1_y, mean_y_f1, mean_x_f1)
dimensionless_dist_pass_f2 <- c(file, cell_count, genotype,2,2, uid,uid_strand, (distance_strand+ distance_strand_2), px_length,foci_location_along_2, dim_length,"pass", foci_2_x, foci_2_y, mean_y_f2, mean_x_f2)
dimensionless_dist_pass_f1 <- c(img_file,cell_count, genotype,1,2, uid,uid_strand,(distance_strand+ distance_strand_2), px_length,foci_location_along_1, dim_length,"pass", foci_1_x, foci_1_y, mean_y_f1, mean_x_f1)
dimensionless_dist_pass_f2 <- c(img_file, cell_count, genotype,2,2, uid,uid_strand, (distance_strand+ distance_strand_2), px_length,foci_location_along_2, dim_length,"pass", foci_2_x, foci_2_y, mean_y_f2, mean_x_f2)
dimensionless_dist_pass <- rbind(dimensionless_dist_pass_f1,dimensionless_dist_pass_f2)
rownames(dimensionless_dist_pass) <- NULL
......@@ -1675,7 +1675,7 @@ get_distance_between_two <- function(distance_strand,distance_strand_2,per_stran
bluered <- rgbImage(ch2, ch1, ch1)
#print("break")
#display(bluered)
print(file)
print(img_file)
### deleting for now
bluered <- rgbImage(ch2, ch3, 0*ch3)
......@@ -1688,11 +1688,11 @@ get_distance_between_two <- function(distance_strand,distance_strand_2,per_stran
}
if(grepl( WT_str, file, fixed = TRUE) == TRUE){
if(grepl( WT_str, img_file, fixed = TRUE) == TRUE){
genotype <- WT_out
}
if(grepl( KO_str, file, fixed = TRUE) == TRUE){
if(grepl( KO_str, img_file, fixed = TRUE) == TRUE){
genotype <- KO_out
}
#dimensionless_dist_fail_minor <- c(file, genotype, px_length,dim_length,(distance_strand+ distance_strand_2),"fail")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment