Commit 2f9f1e4d authored by Robin Engler's avatar Robin Engler
Browse files

Edits (mostly cosmetic) I don't remember exactly.

parent f8919b59
......@@ -132,7 +132,7 @@ loadCellTypeData <- function(combinationFile, markerList){
if(length(markerList)==0) stop("# ERROR: marker list has length zero.")
# Load and check combination file.
# *******************************
# The combination file contains the list of cell types and the list of tissues that we are interested in
......@@ -789,10 +789,10 @@ generateSummaryTable <- function(sampleName, imageIDList, markerList, cellTypeLi
### Indicates whether a cell belongs to a given cell type given the mean marker intensity values of each cell and the
### relassification thresholds that apply to each marker.
### Depending on the value of the threshold, two different methods are used to reclassify cells.
### -> thrshold >= 0: In this case we reclass the values depending on whether they are >= or < than the threshold.
### 1. thrshold >= 0: In this case we reclass the values depending on whether they are >= or < than the threshold.
### values >= threshold get reclassified as 1, while values < threshold get reclassified as 0.
### -> theshold = -1: The -1 is a special value to tell autodesc to use "phenotypeValues" instead of the marker
### intensity values. When -1 is given as a threshold value for a certain maker, autodes will
### 2. theshold = -1: The -1 is a special value to tell autodesc to use "phenotypeValues" instead of the marker
### intensity values. When -1 is given as a threshold value for a certain maker, autodesc will
### look in the "phenotypeValues" string vectors (each value is a cell) and try to find exact
### matches. "exact matches" means that for instance if we are searching for "CD11p", then only
### cells that are phenotyped exactly as "CD11p" will be reclassified to values of 1. Cell with
......@@ -966,12 +966,12 @@ reclassCellByCellType <- function(cellType, intensityTable, thresholdList, pheno
### -> intensity max : maximum ...
### -> intensity SD : standard deviation ...
###
### The function returns a vector with the statistic values in the same order as listed just above.
### The function returns a vector with the statistic values in the same order as listed above.
###
###
### Input arguments:
### -> cellType : String describing cell type, e.g. "CD4", "CD8", "CD4_CD8".
### -> tissueType : String for tissue type, e.g. "Stroma", "Tumor".
### -> tissueType : String for tissue type, e.g. "stroma", "tumor".
### -> intensityTable: Data frame containing MEAN and RECLASSIFIED marker intensity values, in the format as returned
### by the loadMarkerIntensityData() function.
### -> imageID : String giving the imageID value of the subset image for which the statistics should be computed.
......@@ -997,7 +997,7 @@ cellTypeStatistics <- function(cellType, tissueType, intensityTable, imageID="To
names(outputVector) = c("CellCount", "IntMean", "IntMedian", "IntMin", "IntMax", "IntSD")
# Subset intensityTable to keep only the rows that are matching the requested "imageID" and "TissueType" values.
# If the imageID value is != "Total", then we only subset by Tissue type.
# If the imageID value == "Total", then we only subset by Tissue type.
if(imageID == "Total"){
subTable = intensityTable[intensityTable$TissueType==tissueType,]
} else {
......@@ -1005,6 +1005,7 @@ cellTypeStatistics <- function(cellType, tissueType, intensityTable, imageID="To
if(nrow(subTable)==0) stop("# ERROR: no rows matching imageID [",imageID,"]this should not occur.")
subTable = subTable[subTable$TissueType==tissueType,]
}
if(nrow(subTable)==0) stop("# ERROR: no rows matching tissue type [",tissueType,"]this should not occur.")
# Compute statistics for the cell type.
......
......@@ -59,13 +59,12 @@ AUTHORIZED_COMPARTMENT_LIST <<- c("Nucleus", "Membrane", "Cytoplasm", "Entire.Ce
### E.g. "Nucleus", "Membrane" or "Cytoplasm".
### -> vectraVersion : String, the version of vectra software used to generate the data. Different versions of the
### software store their output files (the input for autodesc) in slightly different directories.
### -> phenotypeConfidenceThreshold : Double, threshold value for confidence levels associated to phenotype values.
### This value must be a double in the range 0-100, and indicates whether the cell
### phenotyping is reliable (>= threshold) or not (< threshold). The cell
### phenotyping is the value given in the "Phenotype" column of the marker intensity
### files. The confidence values are given in the "Confidence" column of the same
### files. By default the value of phenotypeConfidenceThreshold is set to 40. To
### ignore any "Confidence" value, set phenotypeConfidenceThreshold to 'NULL'.
### -> phenotypeConfidenceThreshold : Double, threshold value for confidence levels associated with phenotype values.
### This value must be a double in the range 0-100, and indicates whether the cell phenotyping
### is reliable (>= threshold) or not (< threshold). The cell phenotyping is the value given in
### the "Phenotype" column of the marker intensity files. The confidence values are given in the
### "Confidence" column of the same files. By default the value of phenotypeConfidenceThreshold
### is set to 40. To ignore any "Confidence" value, set phenotypeConfidenceThreshold to 'NULL'.
###
autodescMain <- function(sampleDir, paramDir, conversionFactor, compartment, vectraVersion, phenotypeConfidenceThreshold) {
......@@ -143,8 +142,6 @@ autodescMain <- function(sampleDir, paramDir, conversionFactor, compartment, vec
if(is.character(tmp)) return(tmp) # For shiny front-end: test if an error was cought in the above function.
#
# Get list of cell types to search for, and the list of tissue types present in the input data.
#cellTypeList = c(markerList, tmp$cellTypeList)
#cellTypeList = tmp$cellTypeList
cellTypeList = unique(c(paste(markerList,"p",sep=''), tmp$cellTypeList))
tissueList = tmp$tissueList
rm(tmp)
......@@ -153,13 +150,13 @@ autodescMain <- function(sampleDir, paramDir, conversionFactor, compartment, vec
# Load tissue surface data and retrieve imageID list.
# ***************************************************
# Each sample that is analyses with Autodesc can be composed of one or more image files, and each file can be
# Each sample that is analysed with Autodesc can be composed of one or more image files, and each file can be
# identified with a unique imageID value. We can get the imageID values of each image that is part of the sample
# from the names of the "tissue surface" files.
# Note that in the original files, the imageID values contain a "," in them, e.g. "48507,16705", and we replace
# this "," by a "_" so that the imageID values have a format like "48507_16705".
# Get the list of imageID values that are part of the current sample.
#
# Get the list of imageID values that are part of the current sample.
# Make a list of all tissue surface files found in the sample directory.
sampleDir = paste(sampleDir, "/Batch_", sampleName, sep='')
if(!dir.exists(sampleDir)) stop("# ERROR: input directory not found [",sampleDir,"].")
......@@ -186,7 +183,7 @@ autodescMain <- function(sampleDir, paramDir, conversionFactor, compartment, vec
# Load marker intensity data.
# ***************************
# Each sample that is analyses with Autodesc can be composed of one or more image files, and for each image file
# Each sample that is analysed with Autodesc can be composed of one or more image files, and for each image file
# there is a coresponding "marker intensity" file. These files are tables where each row corresponds to a cell
# that was identifed in the sample image, and for each cell the columns give the intensity values for the different
# markers that were used in the experiment.
......@@ -194,7 +191,7 @@ autodescMain <- function(sampleDir, paramDir, conversionFactor, compartment, vec
# Make a list of all marker intensity files found in the sample directory.
markerIntensityFileList = dir(sampleDir, full.names=T, pattern="_cell_seg_data.txt$")
if(length(markerIntensityFileList)==0) stop("# ERROR: cannot find marker intensity file(s) in directory [",
sampleDir,"].")
sampleDir,"].")
#
# Progress report.
cat("### -> marker intensity file(s):", basename(markerIntensityFileList[1]), "\n")
......@@ -224,7 +221,6 @@ autodescMain <- function(sampleDir, paramDir, conversionFactor, compartment, vec
cat("### \n")
# Reclassify marker intensity data (i.e. identify cell types)
# ***********************************************************
......@@ -248,7 +244,7 @@ autodescMain <- function(sampleDir, paramDir, conversionFactor, compartment, vec
# have confidenceValues < phenotypeConfidenceThreshold equal to "NA".
if("Confidence" %in% colnames(intensityTable)){
if(is.null(phenotypeConfidenceThreshold)) stop("# ERROR: phenotypeConfidenceThreshold should not be NULL.")
confidenceValues = as.numeric(intensityTable[,"Confidence"])
confidenceValues = as.numeric(intensityTable$Confidence)
phenotypeValues[which( confidenceValues < phenotypeConfidenceThreshold | is.na(confidenceValues) )] = NA
rm(confidenceValues)
}
......
......@@ -4,7 +4,7 @@
### Edit the section below (Autodesc input parameters) and then run this file with Rscript:
### Rscript autodesc_manualRunCommands.R.
###
### There is no need to edit ### the second section of this file (Autodesc launcher commands).
### There is no need to edit the second section of this file (Autodesc launcher commands).
###
......
......@@ -8,12 +8,11 @@
### -> UPPERCASE = Global variables
### -> fn = file name
### ->
########################################################################################################################
# Global input/output variables for autodesc tests.
# *************************************************
# Samples removed from tests: "samples_vectra3/IMCOL_04", "samples_vectra3/SSCC2", "synthetic/SYNT_01"
###
###
### Global input/output variables for autodesc tests.
### *************************************************
### Samples removed from tests: "samples_vectra3/IMCOL_04", "samples_vectra3/SSCC2", "synthetic/SYNT_01"
SAMPLELIST <- c("samples_vectra2/His2757_7", "samples_vectra3/016000-070-M1", "samples_vectra3/036989-008-M1",
"samples_vectra3/039314-010-M1", "samples_vectra3/15-17217", "samples_vectra3/15-1864_B3")
SAMPLEROOT <- file.path(AUTODESC_GITDIR, "testData/testSet")
......@@ -22,6 +21,9 @@ CONVERSIONF <- 2.46e-07 # Conversion f
VECTRAVER <- 2
COMPARTMENT <- "Nucleus"
###
########################################################################################################################
########################################################################################################################
......@@ -31,7 +33,7 @@ test.main <- function(){
# Loop through all samples to test and run the entire autodesc pipeline for each of them.
for(sampleName in SAMPLELIST){
#sampleName=SAMPLELIST[7]
#sampleName=SAMPLELIST[6]
# Run autodesc.
# *************
......@@ -40,6 +42,7 @@ test.main <- function(){
paramDir = file.path(PARAMROOT, sampleName)
# Run autodesc pipeline.
# conversionFactor=CONVERSIONF; compartment=COMPARTMENT; vectraVersion=VECTRAVER; phenotypeConfidenceThreshold=40
sampleX = autodescMain(sampleDir=sampleDir, paramDir=paramDir, conversionFactor=CONVERSIONF,
compartment=COMPARTMENT, vectraVersion=VECTRAVER,
phenotypeConfidenceThreshold=40)
......@@ -84,7 +87,6 @@ test.main <- function(){
########################################################################################################################
### test.formatExport - test the export table format
### ***********************************************
......@@ -111,6 +113,9 @@ test.formatExport <- function () {
# TO DO : WRITE ASSERTION
}
########################################################################################################################
########################################################################################################################
### test.format4Display - test the export table format
......@@ -126,6 +131,7 @@ test.format4Display <- function () {
}
########################################################################################################################
Markdown is supported
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