Skip to content

Commit

Permalink
not working annotation update
Browse files Browse the repository at this point in the history
  • Loading branch information
NorStorz committed Sep 24, 2024
1 parent 2c72f7b commit a6a0a08
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
28 changes: 15 additions & 13 deletions R/DataProcessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,27 +196,29 @@ readProjectData <- function(fileLines, progress = FALSE)
listMatrixRows <- NULL
listMatrixCols <- NULL

## Disable command line reading of answer
if (FALSE) {

################################################################################
#Start of importing annotation part1 from two
# Display the message and give the user the option to choose whether to upload the annotation file or not.
#If Y shows selection window for annotation file. if N ignores annotation process
#message("Do you want to upload the annotation file? (Y/N)")
#user_choice <- readline()
user_choice <- "N"

if (toupper(user_choice) == "Y") {
if (!is.null(attr(rowData(qfeatures[[1]]), "annotation column"))) {

# column_annot <- attr(rowData(qfeatures[[1]]), "annotation column")
# metaboliteProfile["Annotation"] <- column_annot
# selected_column <- available_columns[selected_column_annot]

# Extract the relevant data: Alignment ID and the annotation column from qfeatures
annot_colname <- attr(rowData(qfeatures[[1]]), "annotation column")
annotation_data <- rowData(qfeatures[[1]])[[annot_colname]]
alignment_ids <- rowData(qfeatures[[1]])[["Alignment ID"]]

# Find the matching indices between metaboliteProfile and annotation_data
matching_indices <- match(metaboliteProfile[["Alignment_ID"]], alignment_ids)

metaboliteProfile$Annotation[!is.na(matching_indices)] <- annotation_data[matching_indices[!is.na(matching_indices)]]

}

#####################################################################################################################################
#end of importing annotation part1 from two
}

listMatrixVals <- NULL

Expand Down Expand Up @@ -276,11 +278,11 @@ readProjectData <- function(fileLines, progress = FALSE)
}

## STN: Disabled.
if (FALSE) {
if (!is.null(attr(rowData(qfeatures[[1]]), "annotation column"))) {
#Start of importing annotation part2 from two
################################################################################
#adding HEX color codes from external annotations to the annotationColorsMapInitValue of dataFrameHeader
if (toupper(user_choice) == "Y") {

# Copy the selected column by user, Remove duplicates and exclude the first row
uniqueAnnotations <- unique(unlist(strsplit(metaboliteProfile$Annotation, ",")))
uniqueAnnotations <- paste0(uniqueAnnotations, "=")
Expand All @@ -295,7 +297,7 @@ readProjectData <- function(fileLines, progress = FALSE)
uniqueAnnotationsHexs <- gsub("AnnotationColors=\\{\\s+", "AnnotationColors={", paste("AnnotationColors={", paste(uniqueAnnotations1, collapse = ","), "}"))
# Assuming dataFrameHeader is your data frame
dataFrameHeader$Annotation[2] <- uniqueAnnotationsHexs
}

################################################################################
#End of importing annotation part2 from two
}
Expand Down
2 changes: 1 addition & 1 deletion R/FragmentMatrixFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ convertToProjectFile <- function(filePeakMatrixPath,
filePeakMatrixQF <- readMSDial(filePeakMatrixPath)
if (!is.null(fileAnnotation)){
# TODO: determine colums to merge by
addSiriusAnnotations(filePeakMatrixQF,fileAnnotation)
filePeakMatrixQF <- addSiriusAnnotations(filePeakMatrixQF,fileAnnotation)
}

returnObj <- convertToProjectFile2(
Expand Down
6 changes: 5 additions & 1 deletion R/parsePeakAbundanceMatrixQF.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ addSiriusAnnotations <- function(qfeatures,
attr(annotatedRowData[[col]], "source") <- "data"
}
}

# Set the annotation column
attr(annotatedRowData, "annotation column") <- "ClassyFire.subclass"

rowData(qfeatures[[1]]) <- annotatedRowData
return(qfeatures)
}
}

0 comments on commit a6a0a08

Please sign in to comment.