[.neuronlist and [<-.neuronlist behave like the corresponding base methods ([.data.frame, [<-.data.frame) allowing extraction or replacement of parts of the data.frame attached to the neuronlist.

droplevels Remove redundant factor levels in dataframe attached to neuronlist

with Evaluate expression in the context of dataframe attached to a neuronlist

head Return the first part of data.frame attached to neuronlist

tail Return the last part of data.frame attached to neuronlist

# S3 method for neuronlist
[(x, i, j, drop)

# S3 method for neuronlist
[(x, i, j) <- value

# S3 method for neuronlist
droplevels(x, except = NULL, ...)

# S3 method for neuronlist
with(data, expr, ...)

# S3 method for neuronlist
head(x, ...)

# S3 method for neuronlist
tail(x, ...)

Arguments

x

A neuronlist object

i, j

elements to extract or replace. Numeric or character or, for [ only, empty. Numeric values are coerced to integer as if by as.integer. See [.data.frame for details.

drop

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.

value

A suitable replacement value: it will be repeated a whole number of times if necessary and it may be coerced: see the Coercion section. If NULL, deletes the column if a single column is selected.

except

indices of columns from which not to drop levels

...

Further arguments passed to default methods (and usually ignored)

data

A neuronlist object

expr

The expression to evaluate

Value

the attached dataframe with levels dropped (NB not the neuronlist)

See also

[.data.frame, @seealso [<-.data.frame

droplevels

with

head

tail

Other neuronlist: *.neuronlist(), is.neuronlist(), neuronlistfh(), neuronlistz(), neuronlist(), nlapply(), read.neurons(), write.neurons()

Examples

## treat kcs20 as data.frame
kcs20[1, ]
#>                                       gene_name         Name idid soma_side
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002 fru-M-500112 1024         L
#>                         flipped   Driver Gender        X       Y        Z
#> FruMARCM-M001205_seg002   FALSE fru-Gal4      M 361.4849 95.0448 84.10259
#>                                        exemplar cluster idx  type
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002       9 156 gamma
kcs20[1:3, ]
#>                                       gene_name          Name  idid soma_side
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002  fru-M-500112  1024         L
#> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616         L
#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010  8399         R
#>                         flipped    Driver Gender        X         Y        Z
#> FruMARCM-M001205_seg002   FALSE  fru-Gal4      M 361.4849  95.04480 84.10259
#> GadMARCM-F000122_seg001   FALSE Gad1-Gal4      F 367.8332 105.86755 94.73446
#> GadMARCM-F000050_seg001    TRUE Gad1-Gal4      F 382.8279  61.73213 97.28057
#>                                        exemplar cluster  idx  type
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002       9  156 gamma
#> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001      70 1519 gamma
#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001      57 1132    ab
kcs20[, 1:4]
#>                                       gene_name          Name  idid soma_side
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002  fru-M-500112  1024         L
#> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616         L
#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010  8399         R
#> GadMARCM-F000142_seg002 GadMARCM-F000142_seg002 Gad1-F-300043 10647         L
#> FruMARCM-F000270_seg001 FruMARCM-F000270_seg001  fru-F-400045  9758         L
#> FruMARCM-F001115_seg002 FruMARCM-F001115_seg002  fru-F-300059  6182         R
#> FruMARCM-M001051_seg002 FruMARCM-M001051_seg002  fru-M-100078  1500         R
#> GadMARCM-F000423_seg001 GadMARCM-F000423_seg001 Gad1-F-300107  9541         R
#> ChaMARCM-F000586_seg002 ChaMARCM-F000586_seg002  Cha-F-300150  7113         R
#> FruMARCM-M001339_seg001 FruMARCM-M001339_seg001  fru-M-300145  1145         R
#> GadMARCM-F000476_seg001 GadMARCM-F000476_seg001 Gad1-F-400089  9612         R
#> FruMARCM-F000085_seg001 FruMARCM-F000085_seg001  fru-F-400017 11472         R
#> FruMARCM-F000706_seg001 FruMARCM-F000706_seg001  fru-F-000031  7810         R
#> FruMARCM-M000842_seg002 FruMARCM-M000842_seg002  fru-M-400058  1689         L
#> FruMARCM-F001494_seg002 FruMARCM-F001494_seg002  fru-F-200098  6341         R
#> FruMARCM-F000188_seg001 FruMARCM-F000188_seg001  fru-F-200021  6405         R
#> GadMARCM-F000071_seg001 GadMARCM-F000071_seg001 Gad1-F-300023 10541         R
#> FruMARCM-M000115_seg001 FruMARCM-M000115_seg001  fru-M-100014  2389         L
#> GadMARCM-F000442_seg002 GadMARCM-F000442_seg002 Gad1-F-700033  9569         R
#> FruMARCM-F001929_seg001 FruMARCM-F001929_seg001  fru-F-400181  4694         L
kcs20[, 'soma_side']
#>  [1] L L R L L R R R R R R R R L R R R L R L
#> Levels: L M R
# alternative to as.data.frame(kcs20)
kcs20[, ]
#>                                       gene_name          Name  idid soma_side
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002  fru-M-500112  1024         L
#> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616         L
#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010  8399         R
#> GadMARCM-F000142_seg002 GadMARCM-F000142_seg002 Gad1-F-300043 10647         L
#> FruMARCM-F000270_seg001 FruMARCM-F000270_seg001  fru-F-400045  9758         L
#> FruMARCM-F001115_seg002 FruMARCM-F001115_seg002  fru-F-300059  6182         R
#> FruMARCM-M001051_seg002 FruMARCM-M001051_seg002  fru-M-100078  1500         R
#> GadMARCM-F000423_seg001 GadMARCM-F000423_seg001 Gad1-F-300107  9541         R
#> ChaMARCM-F000586_seg002 ChaMARCM-F000586_seg002  Cha-F-300150  7113         R
#> FruMARCM-M001339_seg001 FruMARCM-M001339_seg001  fru-M-300145  1145         R
#> GadMARCM-F000476_seg001 GadMARCM-F000476_seg001 Gad1-F-400089  9612         R
#> FruMARCM-F000085_seg001 FruMARCM-F000085_seg001  fru-F-400017 11472         R
#> FruMARCM-F000706_seg001 FruMARCM-F000706_seg001  fru-F-000031  7810         R
#> FruMARCM-M000842_seg002 FruMARCM-M000842_seg002  fru-M-400058  1689         L
#> FruMARCM-F001494_seg002 FruMARCM-F001494_seg002  fru-F-200098  6341         R
#> FruMARCM-F000188_seg001 FruMARCM-F000188_seg001  fru-F-200021  6405         R
#> GadMARCM-F000071_seg001 GadMARCM-F000071_seg001 Gad1-F-300023 10541         R
#> FruMARCM-M000115_seg001 FruMARCM-M000115_seg001  fru-M-100014  2389         L
#> GadMARCM-F000442_seg002 GadMARCM-F000442_seg002 Gad1-F-700033  9569         R
#> FruMARCM-F001929_seg001 FruMARCM-F001929_seg001  fru-F-400181  4694         L
#>                         flipped    Driver Gender        X         Y         Z
#> FruMARCM-M001205_seg002   FALSE  fru-Gal4      M 361.4849  95.04480  84.10259
#> GadMARCM-F000122_seg001   FALSE Gad1-Gal4      F 367.8332 105.86755  94.73446
#> GadMARCM-F000050_seg001    TRUE Gad1-Gal4      F 382.8279  61.73213  97.28057
#> GadMARCM-F000142_seg002   FALSE Gad1-Gal4      F 349.5917  78.18986  96.69280
#> FruMARCM-F000270_seg001   FALSE  fru-Gal4      F 387.5236 114.80344  87.84156
#> FruMARCM-F001115_seg002    TRUE  fru-Gal4      F 352.0216 121.72034 100.52308
#> FruMARCM-M001051_seg002    TRUE  fru-Gal4      M 338.7782 118.68985  95.47755
#> GadMARCM-F000423_seg001    TRUE Gad1-Gal4      F 401.4795  76.32671  97.92564
#> ChaMARCM-F000586_seg002    TRUE  Cha-Gal4      F 340.1020  79.79322  92.21622
#> FruMARCM-M001339_seg001    TRUE  fru-Gal4      M 393.1358 102.42494  92.82986
#> GadMARCM-F000476_seg001    TRUE Gad1-Gal4      F 339.5274  60.45391  94.78038
#> FruMARCM-F000085_seg001    TRUE  fru-Gal4      F 344.0347  78.32091 100.64333
#> FruMARCM-F000706_seg001    TRUE  fru-Gal4      F 406.5796  80.13186  94.32588
#> FruMARCM-M000842_seg002   FALSE  fru-Gal4      M 403.8388  62.06659  89.97595
#> FruMARCM-F001494_seg002    TRUE  fru-Gal4      F 348.3770 115.99559  95.77683
#> FruMARCM-F000188_seg001    TRUE  fru-Gal4      F 329.2778  78.68618  92.02949
#> GadMARCM-F000071_seg001    TRUE Gad1-Gal4      F 341.3460  77.38931  91.88780
#> FruMARCM-M000115_seg001   FALSE  fru-Gal4      M 388.2444  65.12638  91.88102
#> GadMARCM-F000442_seg002    TRUE Gad1-Gal4      F 348.7375  78.76781  89.38335
#> FruMARCM-F001929_seg001   FALSE  fru-Gal4      F 372.0023 115.12707  91.70584
#>                                        exemplar cluster  idx  type
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002       9  156 gamma
#> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001      70 1519 gamma
#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001      57 1132    ab
#> GadMARCM-F000142_seg002 GadMARCM-F000142_seg002      71 1535  apbp
#> FruMARCM-F000270_seg001 FruMARCM-F000270_seg001      64 1331    ab
#> FruMARCM-F001115_seg002 FruMARCM-F001115_seg002      44  795    ab
#> FruMARCM-M001051_seg002 FruMARCM-M001051_seg002      16  268    ab
#> GadMARCM-F000423_seg001 GadMARCM-F000423_seg001      61 1265  apbp
#> ChaMARCM-F000586_seg002 ChaMARCM-F000586_seg002      52  898  apbp
#> FruMARCM-M001339_seg001 FruMARCM-M001339_seg001      12  190    ab
#> GadMARCM-F000476_seg001 GadMARCM-F000476_seg001      63 1295 gamma
#> FruMARCM-F000085_seg001 FruMARCM-F000085_seg001      76 1718 gamma
#> FruMARCM-F000706_seg001 FruMARCM-F000706_seg001      53 1007    ab
#> FruMARCM-M000842_seg002 FruMARCM-M000842_seg002      18  318    ab
#> FruMARCM-F001494_seg002 FruMARCM-F001494_seg002      48  827    ab
#> FruMARCM-F000188_seg001 FruMARCM-F000188_seg001      49  842    ab
#> GadMARCM-F000071_seg001 GadMARCM-F000071_seg001      69 1484 gamma
#> FruMARCM-M000115_seg001 FruMARCM-M000115_seg001      22  406 gamma
#> GadMARCM-F000442_seg002 GadMARCM-F000442_seg002      62 1277 gamma
#> FruMARCM-F001929_seg001 FruMARCM-F001929_seg001      36  610    ab

## can also set columns
kcs13=kcs20[1:3]
kcs13[,'side']=as.character(kcs13[,'soma_side'])
head(kcs13)
#>                                       gene_name          Name  idid soma_side
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002  fru-M-500112  1024         L
#> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001 Gad1-F-900005 10616         L
#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001 Gad1-F-100010  8399         R
#>                         flipped    Driver Gender        X         Y        Z
#> FruMARCM-M001205_seg002   FALSE  fru-Gal4      M 361.4849  95.04480 84.10259
#> GadMARCM-F000122_seg001   FALSE Gad1-Gal4      F 367.8332 105.86755 94.73446
#> GadMARCM-F000050_seg001    TRUE Gad1-Gal4      F 382.8279  61.73213 97.28057
#>                                        exemplar cluster  idx  type side
#> FruMARCM-M001205_seg002 FruMARCM-M001205_seg002       9  156 gamma    L
#> GadMARCM-F000122_seg001 GadMARCM-F000122_seg001      70 1519 gamma    L
#> GadMARCM-F000050_seg001 GadMARCM-F000050_seg001      57 1132    ab    R
# or parts of columns
kcs13[1,'soma_side']='R'
kcs13['FruMARCM-M001205_seg002','soma_side']='L'
# remove a column
kcs13[,'side']=NULL
all.equal(kcs13, kcs20[1:3])
#> [1] TRUE

# can even replace the whole data.frame like this
kcs13[,]=kcs13[,]
all.equal(kcs13, kcs20[1:3])
#> [1] TRUE

## get row/column names of attached data.frame 
# (unfortunately implementing ncol/nrow is challenging)
rownames(kcs20)
#>  [1] "FruMARCM-M001205_seg002" "GadMARCM-F000122_seg001"
#>  [3] "GadMARCM-F000050_seg001" "GadMARCM-F000142_seg002"
#>  [5] "FruMARCM-F000270_seg001" "FruMARCM-F001115_seg002"
#>  [7] "FruMARCM-M001051_seg002" "GadMARCM-F000423_seg001"
#>  [9] "ChaMARCM-F000586_seg002" "FruMARCM-M001339_seg001"
#> [11] "GadMARCM-F000476_seg001" "FruMARCM-F000085_seg001"
#> [13] "FruMARCM-F000706_seg001" "FruMARCM-M000842_seg002"
#> [15] "FruMARCM-F001494_seg002" "FruMARCM-F000188_seg001"
#> [17] "GadMARCM-F000071_seg001" "FruMARCM-M000115_seg001"
#> [19] "GadMARCM-F000442_seg002" "FruMARCM-F001929_seg001"
colnames(kcs20)
#>  [1] "gene_name" "Name"      "idid"      "soma_side" "flipped"   "Driver"   
#>  [7] "Gender"    "X"         "Y"         "Z"         "exemplar"  "cluster"  
#> [13] "idx"       "type"