@@ -107,8 +107,8 @@ read_markers <- function(info) {
107107 obj <- readRDS(info $ path )
108108 df <- as.data.frame(obj , stringsAsFactors = FALSE )
109109
110- # The Uniprot IDs are in the row names
111- uniprot_ids <- rownames(df )
110+ # The protein IDs are in the row names
111+ protein_ids <- rownames(df )
112112
113113 # The compartments are in the 'markers' column
114114 compartments <- df $ markers
@@ -118,17 +118,17 @@ read_markers <- function(info) {
118118
119119 # Create a clean data frame
120120 data <- data.frame (
121- uniprot_id = uniprot_ids ,
121+ id = protein_ids ,
122122 compartment = compartments ,
123123 stringsAsFactors = FALSE
124124 )
125125
126- # Remove rows with missing or empty Uniprot IDs
127- data <- data [! is.na(data $ uniprot_id ) & nzchar(data $ uniprot_id ), ]
126+ # Remove rows with missing or empty protein IDs
127+ data <- data [! is.na(data $ id ) & nzchar(data $ id ), ]
128128
129- # Aggregate by Uniprot ID in case there are duplicates
130- data <- aggregate(data $ compartment , by = list (uniprot_id = data $ uniprot_id ), FUN = collapse_values )
131- names(data ) <- c(" uniprot_id " , info $ author )
129+ # Aggregate by protein ID in case there are duplicates
130+ data <- aggregate(data $ compartment , by = list (id = data $ id ), FUN = collapse_values )
131+ names(data ) <- c(" id " , info $ author )
132132
133133 data
134134}
@@ -152,15 +152,15 @@ for (species in names(species_groups)) {
152152 data_list <- lapply(infos , read_markers )
153153
154154 # Merge all data frames for this species
155- merged <- Reduce(function (x , y ) merge(x , y , by = " uniprot_id " , all = TRUE ), data_list )
155+ merged <- Reduce(function (x , y ) merge(x , y , by = " id " , all = TRUE ), data_list )
156156
157- # Order columns: uniprot_id first, then authors in order
158- ordered_cols <- c(" uniprot_id " , authors )
157+ # Order columns: id first, then authors in order
158+ ordered_cols <- c(" id " , authors )
159159 ordered_cols <- ordered_cols [ordered_cols %in% names(merged )]
160160 merged <- merged [, ordered_cols , drop = FALSE ]
161161
162- # Sort by uniprot_id
163- merged <- merged [order(merged $ uniprot_id ), ]
162+ # Sort by id
163+ merged <- merged [order(merged $ id ), ]
164164
165165 out_file <- file.path(out_dir , paste0(" marker2_" , species , " _merged.csv" ))
166166 write.csv(merged , out_file , row.names = FALSE , na = " " )
0 commit comments