04. Virtual Population
How to create a Virtual Population (VPOP)
A Virtual Population (VPOP) is a cohort of virtual patients created based on statistical distributions or predefined datasets. This section explains how to upload and manage VPOPs using the Jinko API.
Posting a VPOP
You can upload a VPOP from a list of patient dictionaries, from CSV content, or straight from a pandas dataframe. The examples below create a virtual population of 2 patients with 2 descriptors.
From a list of patients
from jinko import JinkoClient
client = JinkoClient()
patients = [
{
"patientIndex": "1",
"patientAttributes": [
{"id": "age", "val": 45},
{"id": "weight", "val": 70},
],
},
{
"patientIndex": "2",
"patientAttributes": [
{"id": "age", "val": 50},
{"id": "weight", "val": 80},
],
},
]
vpop = client.create_vpop_from_patients_list(
patients,
name="Example VPOP",
folder="folder-id-123",
)
From CSV content
from jinko import JinkoClient
client = JinkoClient()
csv_vpop = """patientIndex,age,weight
1,45,70
2,50,80"""
vpop = client.create_vpop_from_csv(
csv_vpop,
name="Example VPOP",
folder="folder-id-123",
)
From a pandas dataframe
import pandas as pd
from jinko import JinkoClient
client = JinkoClient()
df = pd.DataFrame(
{
"patientIndex": ["1", "2"],
"age": [45, 50],
"weight": [70, 80],
}
)
vpop = client.create_vpop_from_dataframe(df, name="Example VPOP")
Additional Resources
For more information about the VPOP format and requirements, check out the VPOP creation guide.