R/neuronlistfh.R
sub-.neuronlistfh.Rd
[.neuronlistfh
extracts either a sublist from a
neuronlistfh (converting it to a regular in memory list in the process)
or its attached data.frame.
# S3 method for neuronlistfh
[(x, i, j, drop)
A neuronlistfh object
elements to extract or replace. Numeric, logical or character or,
for the [ get method, empty. See details and the help for
[.data.frame
.
logical. If TRUE
the result is coerced to the
lowest possible dimension. The default is to drop if only one
column is left, but not to drop if only one row is left.
A new in-memory neuronlist
or when using two subscripts, a
data.frame
- see examples.
Note that if i is a numeric or logical indexing vector, it will be converted internally to a vector of names by using the (sorted) names of the objects in x (i.e. names(x)[i])
neuronlistfh
, [.neuronlist
,
[.data.frame
, [<-.data.frame
,
Other neuronlistfh:
neuronlistfh()
,
read.neuronlistfh()
,
remotesync()
,
write.neuronlistfh()
# make a test neuronlistfh backed by a temporary folder on disk
tf=tempfile('kcs20fh')
kcs20fh<-as.neuronlistfh(kcs20, dbdir=tf)
# get first neurons as an in memory neuronlist
class(kcs20fh[1:3])
#> [1] "neuronlist" "list"
# extract attached data.frame
str(kcs20fh[,])
#> 'data.frame': 20 obs. of 14 variables:
#> $ gene_name: chr "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001" "GadMARCM-F000050_seg001" "GadMARCM-F000142_seg002" ...
#> $ Name : chr "fru-M-500112" "Gad1-F-900005" "Gad1-F-100010" "Gad1-F-300043" ...
#> $ idid : num 1024 10616 8399 10647 9758 ...
#> $ soma_side: Factor w/ 3 levels "L","M","R": 1 1 3 1 1 3 3 3 3 3 ...
#> $ flipped : logi FALSE FALSE TRUE FALSE FALSE TRUE ...
#> $ Driver : chr "fru-Gal4" "Gad1-Gal4" "Gad1-Gal4" "Gad1-Gal4" ...
#> $ Gender : chr "M" "F" "F" "F" ...
#> $ X : num 361 368 383 350 388 ...
#> $ Y : num 95 105.9 61.7 78.2 114.8 ...
#> $ Z : num 84.1 94.7 97.3 96.7 87.8 ...
#> $ exemplar : Factor w/ 96 levels "5HT1bMARCM-M000076_seg001",..: 60 78 76 79 41 45 59 82 6 63 ...
#> $ cluster : int 9 70 57 71 64 44 16 61 52 12 ...
#> $ idx : int 156 1519 1132 1535 1331 795 268 1265 898 190 ...
#> $ type : Factor w/ 3 levels "ab","apbp","gamma": 3 3 1 2 1 1 1 2 2 1 ...
# or part of the data.frame
str(kcs20fh[1:2,1:3])
#> 'data.frame': 2 obs. of 3 variables:
#> $ gene_name: chr "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001"
#> $ Name : chr "fru-M-500112" "Gad1-F-900005"
#> $ idid : num 1024 10616
# data.frame assignment (this one changes nothing)
kcs20fh[1:2,'gene_name'] <- kcs20fh[1:2,'gene_name']
# clean up
unlink(tf, recursive=TRUE)