# Operate on Atlas cohorts and data with entries and exit events

Data extracted from Atlas contain cohort entry and cohort exit dates for each person in the cohort. Retaining this information may be important for the downstream analysis.

The Cohort Operations tool offers an option to **include cohort entry and exit dates into newly created cohorts.** It was presented in the [FinnGen data users meeting 25th Jan 2022](https://www.finngen.fi/en/members/recordings/finngen-data-users-meeting-25th-jan-2022) (at 16min35sec) and [FinnGen data users' meeting 28th June 2022](https://www.finngen.fi/en/members/recordings/finngen-data-users-meeting-28th-june-2022) (at 28min55sec).

**Tip:** Preliminary exploration of cohorts prior CO can be done within Atlas using [Atlas Cohort Characterizations tool](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/atlas/detailed-guide/cohort-characterizations-in-atlas). See an [Example workflow for survival time/endpoint analysis](https://docs.finngen.fi/working-in-the-sandbox/general-workflows-for-the-most-common-analyses).

#### Step 1:

First, [Upload cohorts into the Cohort Operations tool](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/cohort-operations-tool-co/upload-cohorts-to-co). The uploaded cohorts will show up in the Cohorts workbench view. Then click `Operate Cohorts` on the left-hand menu. Guidance for each step is available from ![](https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-39e2cbe05aecb4c9ed987a1c1aa635acc69167d1%2Fimage%20\(201\).png?alt=media).

![](https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-e8220d152b8a2b5248785060092ad29156ee2aa5%2Fimage%20\(851\).png?alt=media)

#### Step 2:

On the `Operate Cohorts` -> `Select new cohort's entry and exit` select entry rules for cohort start and end dates and select one or more cohorts where the data is taken from.

### Example

In the following example, CO will select the earliest COHORT\_START\_DATE and the latest COHORT\_END\_DATE for a person from the Atlas cohorts included in `from` -box (Asthma\[MN] or AllergicRhinitisOrNasalSteroids\[MN]).

In this case, earliest cohort start date is either the first case of Asthma or the first case of Allergic Rhinitis whichever comes earlier for a person. Similarly, the latest cohort end date is from the cohort with latest recording.

![](https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-cf6f73b95cee2bd0465714491ff7bfaa73ca2485%2Fimage%20\(408\).png?alt=media)

The cohort start date [defined by the user in Atlas](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/atlas/detailed-guide/how-to-define-a-cohort-in-atlas) is the approximate date (real date ± 1-15 days) when a person enters the cohort. Usually, the cohort start date is set (in Atlas) to some event e.g. first diagnosis for a condition, or e.g. first recorded event in a person's medical history.

Similarly, a cohort end date is [defined by the user in Atlas](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/atlas/detailed-guide/how-to-define-a-cohort-in-atlas). Note that the Cohort Operation tool selects the earliest or the latest COHORT\_START\_DATE and COHORT\_END\_DATE from the Atlas cohorts, those are indicated in the `from` -box above (here Asthma\[MN] or AllergicRhinitisOrNasalSteroids\[MN]).

Select rules for patient inclusion from `Select new cohort's patients` if you like. The selection of patients is optional and provides further filtering based on a cohort, see [Combine cohorts with CO](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/cohort-operations-tool-co/combine-cohorts-with-co) section. Click `Create New Cohort`.

![](https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-a09c9b62db299a7a0a2abad8b2371f35aa3b0869%2Fimage%20\(538\).png?alt=media)

####

The new combined cohort will appear in the Result cohort view. Here you can see the same summary statistics as when [uploading cohorts from Atlas or from a file](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/cohort-operations-tool-co/upload-cohorts-to-co) with a number of cases and blue and red bars for males and females. Cohort start and end dates are also included as indicated by the blue bars under COHORT\_START\_DATE and COHORT\_END\_DATE. Upload the new cohort directly to the workbench of the same session by clicking the `Copy new cohort to workbench` button.

![](https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-8bdad8ad91aba812917bfb6e2a2e5a18aae445e1%2Fimage%20\(206\).png?alt=media)

On the `Operate Cohorts` -> `Select new cohort's entry and exit` users can select the earliest, the latest, or all entry events and earliest or latest exit events. For comparison let's repeat the cohort creation with the latest cohort start date and earliest cohort end date. Let's repeat the cohort also with all entry events.

![](https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-1eff5149dac91fc274a56e9a13dfd522f3a2112d%2Fimage%20\(259\).png?alt=media)

Click <img src="https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-221a0823b1722054bf4efb9e6772a041eccf2927%2Fimage%20(389).png?alt=media" alt="" data-size="original"> and ![](https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-b651c5ee9a4fc0f33a8860a0f5d03946df094208%2Fimage%20\(199\).png?alt=media).

For comparison let's repeat the cohort also with all entry events.

![](https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-d8211204eee9091af882c5194ace4a3c35ac8a9b%2Fimage%20\(87\).png?alt=media)

Click <img src="https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-221a0823b1722054bf4efb9e6772a041eccf2927%2Fimage%20(389).png?alt=media" alt="" data-size="original"> and ![](https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-b651c5ee9a4fc0f33a8860a0f5d03946df094208%2Fimage%20\(199\).png?alt=media).

On the workbench, we have now three versions of the same cohort. The blue and red bars for males and females are the same in all versions as expected. However, the blue bars indicating cohort entry events are different depending on whether the earliest, the latest, or all entry events are selected.

![](https://3072695768-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MhYL0UTLjqsuIdK0SSO%2Fuploads%2Fgit-blob-e328f6d68694aed6ed6e603defde04e62663741c%2Fimage%20\(203\).png?alt=media)

After uploading the new cohorts to the workbench they are now ready for further operations like [combining with other cohorts](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/cohort-operations-tool-co/combine-cohorts-with-co), [exploration of code and endpoint enrichments](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/cohort-operations-tool-co/explore-code-and-endpoint-enrichments-with-co), or [export of the cohorts](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/cohort-operations-tool-co/export-finngen-ids-using-co).

To export the cohort, see [Export FinnGen IDs using CO](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/cohort-operations-tool-co/export-finngen-ids-using-co). Cohorts are exported with FinnGen IDs, cohort start, and cohort end dates.

**Tip:** Cohorts created with CO can be uploaded and visualized for [timeline trajectories](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/trajectory-visualization-tool-tvt/trajectory-visualization-tool-tvt) per patient, [clustered for HeatMap presentation](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/trajectory-visualization-tool-tvt/trajectory-visualization-tool-tvt/clustering-timelines-with-tvt), and overview plots can be created using [Trajectory Visualization Tool (TVT)](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/trajectory-visualization-tool-tvt).
