Open Petra-P opened 4 years ago
In the initial issue there is a function missing in the first part, it should be:
##Use example peptide data set, read in and clean data
inputFile <- system.file("extdata", "data.txt", package = "ComPrAn")
peptides <- cleanData(data.table::fread(inputFile), fCol = "Search ID")
## optional filtering
peptides <- toFilter(peptides, rank = 1)
## separate chemical modifications and labelling into separate columns
peptides <- splitModLab(peptides)
## remove unneccessary columns, simplify rows
peptides <- simplifyProteins(peptides)
Package workflow at the moment is:
Unchanged functions
Modified function pickPeptide
Now the input is
peptides
data frame and notpeptide_index
environment Output is a names listOld code, does not work any more
peptide_index <- makeEnv(peptides)
for (i in names(peptide_index)) {
assign(i, pickPeptide(peptide_index[[i]]), envir = peptide_index)
}
protein <- "P52815" max_frac <- 23
default plot
allPeptidesPlot(peptide_index,protein, max_frac = max_frac)
Create a list of proteins present in both/only in one label state
listOnlyOneLabState <- onlyInOneLabelState_ENV(peptide_index)
New code:
extract table with normalised protein values for both scenarios
forExport <- getNormTable(peptide_index,purpose = "export") forAnalysis <- getNormTable(peptide_index,purpose = "analysis")
Old code:
normalize proteins
names(peptide_index) %>%
map_df(~ extractRepPeps(peptide_index[[.]], scenario = 'A', label = T)) %>%
normalizeTable() -> protNormLab
names(peptide_index) %>%
map_df(~ extractRepPeps(peptide_index[[.]], scenario = 'A', label = F)) %>%
normalizeTable() -> protNormUnlab
names(peptide_index) %>%
map_df(~ extractRepPeps(peptide_index[[.]], scenario = 'B')) %>%
normalizeTable() -> protNormComb
create table that is saved in tab delimited format
forExport <- normTableForExport(protNormLab, protNormUnlab, protNormComb)
create table that is used in further analysis
forAnalysis <- normTableWideToLong(protNormLab, protNormUnlab, protNormComb)
New code:
Create components necessary for clustering
clusteringDF <- clusterComp(forAnalysis,scenar = "A", PearsCor = "centered")
Create a data frames with cluster assignment
labTab_clust <- assignClusters(.listDf = clusteringDF,sample = "labeled", method = 'complete', cutoff = 0.5) unlabTab_clust <- assignClusters(.listDf = clusteringDF,sample = "unlabeled", method = 'complete', cutoff = 0.5)
Old code:
Extract data frames for clustering:
forAnalysis %>%
as_tibble() %>%
filter(scenario == "A") %>%
select(-scenario) %>%
mutate(
Precursor Area
= replace_na(Precursor Area
, 0)) %>%spread(Fraction,
Precursor Area
) -> forClusteringforClustering[is.na(forClustering)] <- 0
forAnalysis[forAnalysis$scenario == "A",] %>%
select(-scenario) %>%
spread(Fraction,
Precursor Area
) -> forClusteringforClustering[is.na(forClustering)] <- 0
labelledTable <- forClustering[forClustering$isLabel==TRUE,]
unlabelledTable <- forClustering[forClustering$isLabel==FALSE,]
Create distance matrix
labDist <- makeDist(t(select(labelledTable,-c(1:3))), centered = T)
unlabDist <- makeDist(t(select(unlabelledTable,-c(1:3))), centered = T)
Assign clusters to data frames
labelledTable_clust <- assignClusters(labelledTable, labDist,
method = 'average', cutoff = 0.85)
unlabelledTable_clust <- assignClusters(unlabelledTable,unlabDist ,
method = 'average', cutoff = 0.85)
makeBarPlotClusterSummary(labTab_clust, name = 'labeled') makeBarPlotClusterSummary(unlabTab_clust, name = 'unlabeled') tableForClusterExport <- exportClusterAssignments(labTab_clust,unlabTab_clust)