Closed RemyLau closed 4 months ago
Hi RemyLau,
I have the same query. I used to the normalize by row and column respectively, so the coordinates stretch out row-wise and colmn-wise respectively.
Here is my personal code:
min_max_normalize <- function(x) {
return ((x - min(x)) / (max(x) - min(x)))
}
get_normalized_position_dataframe <- function(raw_position_dataframe, zoom_scale = 1000) {
standardized_position_dataframe <- raw_position_dataframe %>%
dplyr::mutate(., x = min_max_normalize(x) * zoom_scale) %>%
dplyr::mutate(., y = min_max_normalize(y) * zoom_scale)
}
First of all, thank you for sharing the code! I noticed that when constructing the spatial Gaussian kernel, the coordinates are first normalized. More specifically,
x
any
are first subtracted by their min values, and then divided by the global maximum.https://github.com/YingMa0107/CARD/blob/dc6a0c82c5239d39507c67202d192551d8e248b6/R/CARD.prop.R#L173-L178
This transformation is pretty similar to the MinMaxScaler in sklearn, except that the max value used here is the global maximum, rather than the column-wise maximum. I'm curious whether there is a specific reason for using the global maximum instead of the columns-wise maximum here.