Skip to content

Commit 741dc65

Browse files
committed
support DIA site level report
1 parent 7341b3f commit 741dc65

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

R/io.R

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,19 @@ readQuantTable <- function(quant_table_path, type = "TMT", level=NULL, log2trans
6565
}
6666
} else { # DIA
6767
if (level == "peptide") {
68-
# validate(fragpipe_DIA_input_test(temp_data))
69-
# temp_data <- temp_data[!grepl("contam", temp_data$Protein),]
70-
temp_data <- temp_data %>% select(.,-c("Proteotypic", "Precursor.Charge")) %>%
71-
group_by(Protein.Group, Protein.Names, Protein.Ids, Genes, Stripped.Sequence) %>%
72-
summarise_if(is.numeric, max, na.rm=T)
73-
temp_data[sapply(temp_data, is.infinite)] <- NA
74-
temp_data$Index <- paste0(temp_data$Protein.Ids, "_", temp_data$Stripped.Sequence)
75-
temp_data <- temp_data %>% select(Index, everything())
68+
if (!"SequenceWindow" %in% colnames(temp_data)) {
69+
# validate(fragpipe_DIA_input_test(temp_data))
70+
# temp_data <- temp_data[!grepl("contam", temp_data$Protein),]
71+
temp_data <- temp_data %>% select(.,-c("Proteotypic", "Precursor.Charge")) %>%
72+
group_by(Protein.Group, Protein.Names, Protein.Ids, Genes, Stripped.Sequence) %>%
73+
summarise_if(is.numeric, max, na.rm=T)
74+
temp_data[sapply(temp_data, is.infinite)] <- NA
75+
temp_data$Index <- paste0(temp_data$Protein.Ids, "_", temp_data$Stripped.Sequence)
76+
temp_data <- temp_data %>% select(Index, everything())
77+
} else {
78+
mut.cols <- colnames(temp_data)[!colnames(temp_data) %in% c("Index", "ProteinID", "Gene", "Peptide", "SequenceWindow")]
79+
temp_data[mut.cols] <- sapply(temp_data[mut.cols], as.numeric)
80+
}
7681
}
7782
}
7883
return(temp_data)
@@ -264,9 +269,14 @@ make_se_from_files <- function(quant_table_path, exp_anno_path, type = "TMT", le
264269
dimnames(data_se) <- list(dimnames(data_se)[[1]], colData(data_se)$sample_name)
265270
colData(data_se)$label <- colData(data_se)$sample_name
266271
} else { # level == "peptide"
267-
data_unique <- make_unique(quant_table, "Protein.Group", "Index")
272+
if ("SequenceWindow" %in% colnames(quant_table)) { # single-site
273+
data_unique <- make_unique(quant_table, "ProteinID", "Index")
274+
} else {
275+
data_unique <- make_unique(quant_table, "Protein.Group", "Index")
276+
}
268277
cols <- colnames(data_unique)
269-
selected_cols <- which(!(cols %in% c("Index", "Protein.Group", "Protein.Ids", "Stripped.Sequence", "Protein.Names", "Genes", "First.Protein.Description", "ID", "name")))
278+
selected_cols <- which(!(cols %in% c("Index", "Protein.Group", "Protein.Ids", "Stripped.Sequence", "Protein.Names", "Genes", "First.Protein.Description", "ID", "name",
279+
"Gene", "ProteinID", "Peptide", "SequenceWindow")))
270280
# test_match_DIA_column_design(data_unique, selected_cols, exp_design)
271281
data_se <- make_se_customized(data_unique, selected_cols, exp_design, log2transform=log2transform, exp="DIA", level="peptide")
272282
dimnames(data_se) <- list(dimnames(data_se)[[1]], colData(data_se)$sample_name)

0 commit comments

Comments
 (0)