Select, remove (or duplicate) rows from all views in a composition by their row locations or according to conditions based on a specific view.
Arguments
- current.views
the current view composition.
- rows
row (integer) location; positive values to keep (duplicate) and/or negative to remove.
- view
the name of the view to be used for filtering.
- ...
logical expressions defined in terms of the variables in
view
passed on todplyr::filter()
.
Details
The values in rows
have priority over the other parameters. If
rows
doesn't contain integer values then filtering
is performed based on the view specified in view
and expressions
(...
) returning logical values
defined in terms of the variables in view
.
See also
<data-masking
>.
Other view manipulation functions:
rename_view()
,
select_markers()
Examples
# Create a view composition with an intraview and filter
library(dplyr)
# get the expression data
data("synthetic")
expr <- synthetic[[1]] %>% select(-c(row, col, type))
# compose
misty.views <- create_initial_view(expr)
# select only the first 10 spatial units and preview
misty.views %>%
filter_views(1:10) %>%
str()
#> List of 2
#> $ intraview :List of 2
#> ..$ abbrev: chr "intra"
#> ..$ data : tibble [10 × 11] (S3: tbl_df/tbl/data.frame)
#> .. ..$ ECM : num [1:10] 0.0385 0.0327 0.1444 0.387 0.1635 ...
#> .. ..$ ligA : num [1:10] 0.834 0.119 0.525 0.269 0.195 ...
#> .. ..$ ligB : num [1:10] 0.0157 0.0104 0.014 0.0367 0.1176 ...
#> .. ..$ ligC : num [1:10] 0.236 0.804 0.334 0.502 0.232 ...
#> .. ..$ ligD : num [1:10] 1.183 0.101 0.434 0.241 0.203 ...
#> .. ..$ protE: num [1:10] 1.18 0 1.67 0 0 ...
#> .. ..$ protF: num [1:10] 2.547 0.386 1.614 0.913 0.162 ...
#> .. ..$ prodA: num [1:10] 0.382 0 0.472 0 0 ...
#> .. ..$ prodB: num [1:10] 0 0 0 0 0.16 ...
#> .. ..$ prodC: num [1:10] 0 0.536 0 0.418 0 ...
#> .. ..$ prodD: num [1:10] 0.588 0 0.379 0 0 ...
#> $ misty.uniqueid: chr "b98ad35f4e671871cba35f2155228612"
# select only the units where the expression of ligA is larger than 0.5
# and preview
misty.views %>%
filter_views(NA, "intraview", ligA > 0.5) %>%
str()
#> List of 2
#> $ intraview :List of 2
#> ..$ abbrev: chr "intra"
#> ..$ data : tibble [213 × 11] (S3: tbl_df/tbl/data.frame)
#> .. ..$ ECM : num [1:213] 0.0385 0.1444 0.0307 0.2313 0.0181 ...
#> .. ..$ ligA : num [1:213] 0.834 0.525 0.817 0.514 0.554 ...
#> .. ..$ ligB : num [1:213] 0.0157 0.014 0.0186 0.0313 0.0117 ...
#> .. ..$ ligC : num [1:213] 0.236 0.334 0.156 0.242 0.25 ...
#> .. ..$ ligD : num [1:213] 1.183 0.434 1.092 0.674 0.699 ...
#> .. ..$ protE: num [1:213] 1.178 1.669 0.779 1.21 1.249 ...
#> .. ..$ protF: num [1:213] 2.55 1.61 2.51 1.63 1.7 ...
#> .. ..$ prodA: num [1:213] 0.382 0.472 0.455 0.443 0.401 ...
#> .. ..$ prodB: num [1:213] 0 0 0 0 0 0 0 0 0 0 ...
#> .. ..$ prodC: num [1:213] 0 0 0 0 0 0 0 0 0 0 ...
#> .. ..$ prodD: num [1:213] 0.588 0.379 0.536 0.584 0.458 ...
#> $ misty.uniqueid: chr "b98ad35f4e671871cba35f2155228612"