choose_annotation_colnames: Choose interesting annotation colnames from a data.frame

choose_annotation_colnamesR Documentation

Choose interesting annotation colnames from a data.frame

Description

Choose interesting annotation colnames from a data.frame

Usage

choose_annotation_colnames(
  df,
  min_reps = 2,
  min_values = 2,
  max_values = Inf,
  keep_numeric = FALSE,
  simplify = TRUE,
  max_colnames = 20,
  ...
)

Arguments

df

data.frame with annotations that could be interesting to display at the top or side of a heatmap.

min_reps

numeric minimum number of replicates required for a column to be considered interesting. For example, min_reps=3 would require any value in a column to be repeated at least 3 times for that column to be interesting. This filter is intended to remove columns whose values are all unique, such as row identifiers.

min_values

numeric minimum number of unique values required for a column to be considered interesting.

max_values

numeric maximum number of unique values required for a column to be considered interesting. Too many values and the interest is lost. Also, too many values, and the color key becomes unbearable with too many labels.

keep_numeric

logical indicating whether to keep columns with numeric values. When keep_numeric == TRUE it will override the rules above.

simplify

logical indicating whether to filter out columns whose data already matches another column with 1:1 cardinality. This step requires platjam::cardinality() until that function is moved into the jamba package.

max_colnames

numeric maximum number of colnames to return. Note that columns are not sorted for priority, so they will be returned in the order they appear in df after applying the relevant criteria.

...

additional arguments are ignored.

Value

character vector of colnames in df that meet the criteria. If no colnames meet the criteria, this function returns NULL.

See Also

Other jamses utilities: contrast2comp_dev(), fold_to_log2fold(), intercalate(), list2im_opt(), log2fold_to_fold(), make_block_arrow_polygon(), mark_stat_hits(), matrix_normalize(), point_handedness(), point_slope_intercept(), shortest_unique_abbreviation(), shrinkDataFrame(), shrink_df(), shrink_matrix(), sort_samples(), strsplitOrdered(), sub_split_vector(), update_function_params(), update_list_elements()

Examples

df <- data.frame(
   threereps=paste0("threereps_", letters[c(1,1,1,3,5,7,7)]),
   time=paste0("time_", letters[c(1:7)]),
   tworeps=paste0("tworeps_", letters[c(12,12,14,14,15,15,16)]),
   num=sample(1:7),
   class=paste0("class_", LETTERS[c(1,1,1,3,5,7,7)]),
   blah=rep("blah", 7),
   maxvalues=c("one", "two", "three", "four", "five", "six", "six"))
df

choose_annotation_colnames(df)
df[,choose_annotation_colnames(df)]

choose_annotation_colnames(df, max_values=5)
df[,choose_annotation_colnames(df, max_values=5)]

choose_annotation_colnames(df, simplify=FALSE)
df[,choose_annotation_colnames(df, simplify=FALSE)]

choose_annotation_colnames(df, min_reps=3)

choose_annotation_colnames(df, min_reps=1)

choose_annotation_colnames(df, keep_numeric=TRUE)

choose_annotation_colnames(df, min_reps=1)

choose_annotation_colnames(df, min_reps=1, keep_numeric=TRUE)


jmw86069/jamses documentation built on Nov. 4, 2024, 9:25 p.m.