-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
93 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#' @describeIn add_ add_ | ||
#' Add ancestor | ||
#' | ||
#' Add annotations generated with a Large Language Model. | ||
#' @param annot GPT annotation data. | ||
#' @param annot_cols Columns to add. | ||
#' @export | ||
#' @examples | ||
#' phenos <- example_phenos() | ||
#' phenos2 <- add_gpt_annotations(phenos) | ||
add_gpt_annotations <- function(phenos, | ||
annot = gpt_annot_codify( | ||
reset_tiers_dict=TRUE | ||
)$annot_weighted, | ||
annot_cols = names(annot)[ | ||
!names(annot) %in% c("hpo_id","hpo_name") | ||
], | ||
gpt_filters=rep(list(NULL), | ||
length(annot_cols))|> | ||
`names<-`(annot_cols), | ||
force_new = FALSE){ | ||
#### Force new columns #### | ||
if(force_new){ | ||
messager("Force new. Removing existing annot columns.") | ||
rm_cols <- annot_cols[annot_cols %in% names(phenos)] | ||
if(length(rm_cols)>0) phenos[,(rm_cols):=NULL] | ||
} | ||
#### Check for existing columns #### | ||
if(all(annot_cols %in% names(phenos))){ | ||
messager("Ancestor columns already present. Skipping.") | ||
}else { | ||
phenos <- data.table::merge.data.table(phenos, | ||
annot[,-c("hpo_name")], | ||
by= "hpo_id", | ||
all.x = TRUE) | ||
} | ||
#### Filter #### | ||
phenos <- KGExplorer::filter_dt(dat=phenos, | ||
filters = gpt_filters) | ||
#### Return ##### | ||
return(phenos) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.