@@ -170,6 +170,25 @@ mx.convert_probe <- function(probes, probe_type = NULL, target_id = "ID") {
170170 return (ids )
171171}
172172
173+
174+ # '
175+ # '
176+ # ' @export
177+ getLipidAnnotation <- function (probes ,
178+ extra_annot = TRUE ,
179+ annot_table = NULL
180+ ) {
181+ annot <- getMetaboliteAnnotation(
182+ probes ,
183+ db = c(" lipids" ," refmet" ),
184+ extra_annot = extra_annot ,
185+ annot_table = annot_table ,
186+ prefix.symbol = FALSE
187+ )
188+ return (annot )
189+ }
190+
191+
173192# '
174193# '
175194# ' @export
@@ -845,11 +864,9 @@ mx.annotateLipids <- function(name, db=c("rgoslin","refmet","ramp"),
845864 orig.name <- name
846865 name <- sub(" [.][1-9]$" ," " ,name )
847866 names(name ) <- orig.name
848-
849867
850868 # # First we try annotating with their original IDs.
851- aa <- mx.annotateLipids.000(name , db = db , harmonize = harmonize ,
852- add_id = TRUE )
869+ aa <- mx.annotateLipids.000(name , db = db , harmonize = harmonize , add_id = TRUE )
853870 id.cols <- c(" CHEBI_ID" ," HMDB_ID" ," LIPIDMAPS_ID" ," KEGG_ID" ," REFMET_ID" )
854871
855872 # # If there are still unmapped IDs, we try with their synonyms.
@@ -864,15 +881,17 @@ mx.annotateLipids <- function(name, db=c("rgoslin","refmet","ramp"),
864881 if (nrow(S )> 0 ) {
865882 synonyms <- S [," synonymID" ]
866883 db2 <- setdiff(db , " rgoslin" )
867- bb <- mx.annotateLipids.000(synonyms , db = db2 , harmonize = harmonize ,
868- add_id = FALSE )
884+ bb <- mx.annotateLipids.000(synonyms , db = db2 , harmonize = harmonize , add_id = FALSE )
885+
869886 bb <- cbind( inputID = S [," inputID" ], bb )
870887 bb <- bb [order(rowSums(bb == ' -' )),]
871888 bb <- bb [match(idx , bb $ inputID ),]
872889 bb <- bb [,which(colnames(bb ) %in% colnames(aa ))]
873- kk <- match(colnames(bb ),colnames(aa ))
890+
891+ kk <- match(colnames(bb ),colnames(aa ))
874892 jj <- which(aa [ii ,kk ]== ' -' & bb != ' -' , arr.ind = TRUE )
875- if (length(jj )) {
893+
894+ if (nrow(jj ) > 0 ) {
876895 message(" filled " , nrow(jj ), " entries with synonym IDs" )
877896 aa [ii ,kk ][jj ] <- bb [jj ]
878897 }
@@ -886,14 +905,14 @@ mx.annotateLipids <- function(name, db=c("rgoslin","refmet","ramp"),
886905# ' annotate with given ID.
887906# '
888907mx.annotateLipids.000 <- function (name , db = c(" rgoslin" ," refmet" ," ramp" ),
889- add_id = TRUE , harmonize = TRUE , verbose = 1 ) {
890-
908+ add_id = TRUE , harmonize = TRUE , verbose = 1 ) {
909+
891910 COLS <- c(" Input.name" ," Standardized.name" ," Formula" ," Exact.mass" ,
892911 " Super.class" ," Main.class" ," Sub.class" ," Source" )
893912 df <- as.data.frame(matrix (' -' ,nrow = length(name ),ncol = length(COLS )))
894913 colnames(df ) <- COLS
895914 df $ Input.name <- name
896-
915+
897916 for (d in db ) {
898917
899918 missing <- (df $ Formula %in% c(NA ," " ," -" ) & ! name %in% c(NA ," " ," -" ))
@@ -970,8 +989,6 @@ mx.annotateLipids.000 <- function(name, db = c("rgoslin","refmet","ramp"),
970989 }
971990 }
972991
973- # df$Input.name <- orig.name
974-
975992 missing <- (df $ Formula %in% c(NA ," " ," -" ))
976993 if (verbose > 0 ) message(" annotated " ,sum(! missing )," /" ,nrow(df )," features" )
977994
@@ -982,7 +999,7 @@ mx.annotateLipids.000 <- function(name, db = c("rgoslin","refmet","ramp"),
982999 df $ Main.class <- mx.harmonizeMainclassNames(df $ Main.class )
9831000 df $ Super.class <- mx.harmonizeSuperclassNames(df $ Super.class )
9841001 }
985-
1002+
9861003 # # Retrieve cross-reference mapping to other IDs
9871004 if (add_id ) {
9881005 xref <- mx.get_metabolite_mapping(
@@ -991,7 +1008,7 @@ mx.annotateLipids.000 <- function(name, db = c("rgoslin","refmet","ramp"),
9911008 xref $ input_ID <- NULL
9921009 df <- cbind(df , xref )
9931010 }
994-
1011+
9951012 return (df )
9961013}
9971014
0 commit comments