Skip to contents

Walks id_provenance, where each row links a file to one parent file (HTAN_Parent_Data_File_ID) and to the biospecimens and participant it was derived from. htan_lineage() follows those links up (to the Level 1 files a processed file came from), down (to everything derived from a file), or both.

Usage

htan_lineage(
  ids,
  direction = c("ancestors", "descendants", "both"),
  max_depth = 20L,
  con = htan_con()
)

Arguments

ids

character(). HTAN_Data_File_IDs, or a table with an HTAN_Data_File_ID column such as the result of htan_files().

direction

One of "ancestors" (default), "descendants" or "both".

max_depth

integer(1). Stop after this many generations.

con

A connection from htan_con().

Value

A lazy tbl_duckdb_connection with one row per (query file, related file): HTAN_Data_File_ID (the query), related_file_id, depth (0 for the file itself; negative for ancestors, positive for descendants), and the related file's Component, Filename, entityId, HTAN_Participant_ID, HTAN_Assayed_Biospecimen_ID and HTAN_Originating_Biospecimen_ID (comma-separated when several).

Examples

fixture <- system.file("extdata", "snapshot", package = "HTAN")
con <- htan_con("r7", base_url = fixture)
l4 <- htan_files(assay == "ScRNA-seq", level == 4, con = con)
htan_lineage(l4, con = con)
#> # A query:  ?? x 9
#> # Database: DuckDB 1.5.6 [unknown@Linux 7.0.0-1017-azure:R 4.6.1/:memory:]
#>    HTAN_Data_File_ID related_file_id   depth Component        Filename  entityId
#>    <chr>             <chr>             <int> <chr>            <chr>     <chr>   
#>  1 HTA5_0000_1003257 HTA5_0000_1003129    -3 ScRNA-seqLevel1  HTAN DFC… syn5127…
#>  2 HTA5_0000_1003297 HTA5_0000_1003129    -3 ScRNA-seqLevel1  HTAN DFC… syn5127…
#>  3 HTA5_0000_1003297 HTA5_0000_1003130    -3 ScRNA-seqLevel1  HTAN DFC… syn5127…
#>  4 HTA5_0000_1003297 HTA5_0000_1003132    -3 ScRNA-seqLevel1  HTAN DFC… syn5127…
#>  5 HTA5_0000_1003297 HTA5_0000_1003133    -3 ScRNA-seqLevel1  HTAN DFC… syn5127…
#>  6 HTA5_0000_1003297 HTA5_0000_1003140    -3 ScRNA-seqLevel1  HTAN DFC… syn5127…
#>  7 HTA5_0000_1003297 HTA5_0000_1003142    -3 ScRNA-seqLevel1  HTAN DFC… syn5127…
#>  8 HTA12_251_4000    HTA12_251_1014       -3 ScATAC-seqLevel1 snATAC-S… syn5321…
#>  9 HTA12_253_4001    HTA12_253_1001       -3 ScRNA-seqLevel1  snRNA-Se… syn6146…
#> 10 HTA5_0000_1003255 HTA5_0000_1003134    -3 ScRNA-seqLevel1  HTAN DFC… syn5127…
#> # ℹ more rows
#> # ℹ 3 more variables: HTAN_Participant_ID <chr>,
#> #   HTAN_Assayed_Biospecimen_ID <chr>, HTAN_Originating_Biospecimen_ID <chr>