Skip to content

Commit fe073a5

Browse files
committed
rebase
Merge branch 'unnest_SE' of https://github.com/stemangiola/tidySummarizedExperiment into unnest_SE # Conflicts: # R/tidyr_methods.R
2 parents fd82ecd + d723794 commit fe073a5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

R/tidyr_methods.R

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,25 @@ unnest_summarized_experiment <- function(data, cols, ..., keep_empty=FALSE, pt
158158
# If both nested not by transcript nor sample
159159
if(! s_(se)$name %in% colnames(data) & !f_(se)$name %in% colnames(data) ){
160160

161-
se = pull(data, !!cols) %>% .[[1]]
161+
my_se = pull(.data_, !!cols) %>% .[[1]]
162+
162163

163164
# Mark if columns belong to feature or sample
164165
my_unnested_tibble =
165166
mutate(data, !!cols := map(!!cols, ~ as_tibble(.x))) %>%
166-
select(-suppressWarnings( one_of(s_(se)$name, f_(se)$name))) %>%
167+
168+
select(-suppressWarnings( one_of(s_(my_se)$name, f_(my_se)$name))) %>%
167169
unnest(!!cols)
168170

169171
# Get which column is relative to feature or sample
170-
sample_columns = my_unnested_tibble %>% get_subset_columns(!!s_(se)$symbol)
171-
transcript_columns = my_unnested_tibble %>% get_subset_columns(!!f_(se)$symbol)
172+
sample_columns = my_unnested_tibble %>% get_subset_columns(!!s_(my_se)$symbol)
173+
transcript_columns = my_unnested_tibble %>% get_subset_columns(!!f_(my_se)$symbol)
172174

173175
source_column =
174176
c(
175-
rep(s_(se)$name, length(sample_columns)) %>% setNames(sample_columns),
176-
rep(f_(se)$name, length(transcript_columns)) %>% setNames(transcript_columns)
177+
rep(s_(my_se)$name, length(sample_columns)) %>% setNames(sample_columns),
178+
rep(f_(my_se)$name, length(transcript_columns)) %>% setNames(transcript_columns)
179+
177180
)
178181

179182
# Drop if SE is null
@@ -191,14 +194,14 @@ unnest_summarized_experiment <- function(data, cols, ..., keep_empty=FALSE, pt
191194

192195
# Attach back the columns used for nesting
193196
.data_ %>%
194-
select(-!!cols, -suppressWarnings( one_of(s_(se)$name, f_(se)$name))) %>%
197+
select(-!!cols, -suppressWarnings( one_of(s_(my_se)$name, f_(my_se)$name))) %>%
195198
slice(rep(.y, ncol(.x) * nrow(.x))),
196199

197200
# Column sample-wise or feature-wise
198201
column_belonging =
199202
source_column[
200203
.data_ %>%
201-
select(-!!cols, -suppressWarnings( one_of(s_(se)$name, f_(se)$name))) %>%
204+
select(-!!cols, -suppressWarnings( one_of(s_(my_se)$name, f_(my_se)$name))) %>%
202205
colnames()
203206
]
204207
)

0 commit comments

Comments
 (0)