Building a Corpus from Files and APIs

R-CMD-check pkgdown CRAN status Codecov test coverage CRAN downloads CRAN downloads total License: MIT Lifecycle: experimental

File ingestion

scimapR reads 12 bibliographic formats with native clean-room parsers.

# List available example files
sm_example_files()
#>  [1] "example_affiliation_postcode.csv"    
#>  [2] "example_dimensions.csv"              
#>  [3] "example_journal_index.csv"           
#>  [4] "example_lens.csv"                    
#>  [5] "example_openalex_inverted.json"      
#>  [6] "example_openalex.json"               
#>  [7] "example_pubmed.xml"                  
#>  [8] "example_realuse_affiliation_dict.csv"
#>  [9] "example_realuse_corpus.rds"          
#> [10] "example_realuse_reference.csv"       
#> [11] "example_ror.csv"                     
#> [12] "example_scopus.csv"                  
#> [13] "example_self_citation_corpus.rds"    
#> [14] "example_sparse.bib"                  
#> [15] "example_wos.txt"                     
#> [16] "example.bib"                         
#> [17] "example.ris"
# Read a BibTeX file
bib_path <- sm_example_files("example.bib")
corpus_bib <- sm_read_bib(bib_path)
#> ℹ Reading BibTeX file:
#>   '/tmp/RtmpPAHkFS/Rinst1de117df6e59/scimapR/extdata/example.bib'
#> ℹ Parsed 3 BibTeX entries.
print(corpus_bib)
#> 
#> ── <sm_corpus> ─────────────────────────────────────────────────────────────────
#> Works: 3 | Authors: 9 | Institutions: 0
#> Years: 2022 - 2024
#> Sources (journals): 2
#> Embeddings: none
#> Provenance: bibtex (3)
#> Status: Unlocked (last refreshed: never)
# Read an RIS file
ris_path <- sm_example_files("example.ris")
corpus_ris <- sm_read_ris(ris_path)
#> ℹ Reading RIS file:
#>   '/tmp/RtmpPAHkFS/Rinst1de117df6e59/scimapR/extdata/example.ris'
#> ℹ Parsed 3 RIS records.
nrow(corpus_ris$works)
#> [1] 3

Combining multiple sources

combined <- sm_build_corpus(corpus_bib, corpus_ris, dedupe = TRUE)
#> ℹ Re-keyed 3 works, 0 authors, 0 sources and 0 institutions in the second
#>   corpus.
#> ℹ 3 works share a DOI with the first corpus; use `sm_dedupe()` to remove
#>   duplicates.
#> ✔ Removed 3 duplicate works with the same doi.
nrow(combined$works)
#> [1] 3

Auto-detection

corpus_auto <- sm_read_auto(bib_path)
#> ℹ Detected format: "bibtex"
#> ℹ Reading BibTeX file:
#>   '/tmp/RtmpPAHkFS/Rinst1de117df6e59/scimapR/extdata/example.bib'
#> ℹ Parsed 3 BibTeX entries.
nrow(corpus_auto$works)
#> [1] 3

API fetching

For API-based ingestion, set your email for polite pool access:

Sys.setenv(SCIMAPR_MAILTO = "[email protected]")

# Fetch from OpenAlex
corpus <- sm_fetch_openalex(
 query = "spatial transcriptomics colorectal cancer",
 n_max = 100
)

All API fetchers populate the provenance table for reproducibility tracking.

Deduplication

corpus <- sm_example_corpus()
deduped <- sm_dedupe(corpus)

Validation

issues <- sm_validate(corpus)
nrow(issues)
#> [1] 0