Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export(load_regional_univariate_data)
export(load_rss_data)
export(load_tsv_region)
export(load_twas_weights)
export(map_data_type)
export(mash_pipeline)
export(mash_rand_null_sample)
export(merge_mash_data)
Expand Down
20 changes: 20 additions & 0 deletions R/file_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -980,3 +980,23 @@ batch_load_twas_weights <- function(twas_weights_results, meta_data_df, max_memo
names(batches) <- NULL
return(batches)
}


#' Map data type for twas weight contexts based on provided data type table.
#' @param data_type_table A data frame contains three columns: type, context, subgroup
#' @param context_names A vector of contexts
#' @return A vector of mapped data type based on context names
#' @export
map_data_type <- function(data_type_table, context_names){
data_type <- lapply(context_names, function(context){
xqtl_type_table$type[apply(xqtl_type_table, 1, function(x) {
if (! grepl("sQTL",context)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chunmingl am not entirely sure what we are trying to do here but anything hard-coded is not good. If you want to map data, we should take proper regular expression (search for " regex in R" ) then we provide some external files called qtl_type_mapping that look like this:

sQTL, "clu_(\\d+_[+-.]):"

which is the pattern for sQTL event names.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just as an exmaple. Then you load this external file and use this to help you identify the correct data types

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, I will update the function using regex

grepl(x[2], context)
} else {
grepl(x[2], context) & grepl(x[3], context)
}
})]
})
names(data_type) <- context_names
return(data_type)
}
19 changes: 19 additions & 0 deletions man/map_data_type.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading