Deleting specimens dennisw  2015-01-14 06:36
Status: Closed
 
What is the best way to go about deleting specimens from a study? One of our admins would like to be able to bring in 'dummy' specimens when first setting up a study and then delete them. However, is there a way to easily delete those specimens either via the UI or a deleteRows API call?

Thanks
 
 
Jon (LabKey DevOps) responded:  2015-01-14 12:51
Hi Dennis,

There's a couple of ways to delete specimens from a study. One option is to Import in new specimens to replace the dummy ones. The other option is to delete all the vials, which would remove the specimen records from the database.

To do a new import, just go to the Overview tab and click Manage Files. Then upload your specimens file and select the option to Import Data and then Import. If you select the Replace option, that will wipe out the dummy specimen data from earlier and replace it with your new specimen data.

If you want to delete the vials instead, make sure your Specimen Repository Type is setup as "Advanced (External) Specimen Repository" under the Manage Tab > Change Repository Type, then change set the Specimen Data to "Editable" and click Submit. Then you can go into the Specimen Data tab, view all specimens by Individual Vial and then select all and click the Delete option. This option is however the most cumbersome since you have to manually delete so many in one go, so I would advise using the file replacement option mentioned earlier.

Does this help?

Regards,

Jon
 
dennisw responded:  2015-01-14 12:54
Yes, thanks!
 
priggs responded:  2015-01-15 06:41
Hi Jony,

On further testing, Dennis and I found that neither of these methods really works right. Selecting rows and deleting them individually only works on available vials--the unavailable ones can't be selected. As for the import/replace option, it works as described IF there are new specimens in the import package. If we import a specimens.tsv with no rows, it will not remove any existing specimens, but it will blank all of their primary types. I should point out that we're using the study import feature for this, rather than the Import Data option you describe.

Thanks,
Peter
 
Jon (LabKey DevOps) responded:  2015-01-15 09:56
Peter/Dennis,

My apologies. The assumption was that the dummy data would have been replaced with new data, not a specimens.tsv with zero rows.

Can you give us some more details as to what you're trying to do? Are you trying to just remove the dummy data after you've worked with it and have no data afterwards or are you planning on removing the dummy data and replacing it?

Regards,

Jon
 
priggs responded:  2015-01-15 10:14
When we do our initial study setup, there generally aren't any real specimens to use, but I'd like to feed some dummy data through the system to make sure everything works. Once testing is done we want to get rid of the fake vials. For purposes of this testing, it sounds like we could just make sure all the dummy vials are "available" and then delete them from the vial view. My only hesitation is that this feels like a workaround, and I'd really like to know the "official" method of deleting specimens when the issue inevitably comes up again.
 
Jon (LabKey DevOps) responded:  2015-01-15 15:30
Peter,

Thanks for the additional information. So officially at this time, there isn't a way to just delete the specimens directly beyond deleting vials and the replacement via the data import mentioned earlier.

That being said, there is a bug that I am going to file on the vials page issue where the unavailable ones are not selectable for deleting. That definitely shouldn't be behaving that way.

Regarding the zero row specimens.tsv file, was the file apart of a .specimen archive with labs.tsv and other tsv files? Also, when you did the Study Import, did you make sure that your zip file under /study/specimens/ only had a specimen_settings.xml file?

I found that if I created a study for the dummy specimens and verified the study was fine, I would export the study without the specimen data and then re-import that information back in as a new study with no specimen data (thereby allowing me to delete the previous study I made with the dummy specimen data). Have you tried this approach? It would definitely give you what you want - a study to test the dummy data against, confirming the study is good to use, then ending up with a fresh study with no specimen data.

Regards,

Jon
 
priggs responded:  2015-01-16 08:28
Jon,

Good to know, thanks. If you want to reproduce what I'm doing with the empty package, just export an existing study and uncheck all the boxes except specimens (no specimen settings). Then extract the specimens.tsv from the .specimens file, delete all rows (but leave the headers), and pack everything back up again. If this archive is imported to a new folder it creates a study with no specimens, but if it's imported onto an existing study with specimens it simply removes all their primary/derivative types.

That should answer your questions, but just to make sure we're on the same page:
-Specimens.tsv is in a .specimens archive along with labs.tsv and the others.
-There is no specimen_settings.xml file.

Importing the study to a new folder would work content-wise, but half of what we're testing is non-LabKey infrastructure that points to a specific location, so moving the study elsewhere after we're done testing would defeat the purpose. Fortunately we have the vial-deletion workaround mentioned above; I'm just surprised there isn't a more codified way of doing this.

Thanks,
Peter
 
Jon (LabKey DevOps) responded:  2015-01-16 09:54
Peter,

I've found some interesting things here. Based on my testing, I've found:

- If you have zero records in the specimens.tsv file in your .specimens archive, it will not do a replace.
- If you have at least one record in the specimens.tsv file, that will remove all the existing records and you will only see one record when you look at the specimen data.

So another alternative is to have one record in the specimens.tsv file in your archive to upload and replace all the dummy data and then delete that one record in lieu of having to have a vial on every record to do the delete.

The bug I've entered last night (https://www.labkey.org/issues/home/Developer/issues/details.view?issueId=22304) should address your needs on a codified level for sure in one of the 15.X releases in the near future.

Let me know if you have any further questions or concerns on this.

Regards,

Jon
 
Jon (LabKey DevOps) responded:  2015-01-20 15:45
Peter/Dennis,

The bug (https://www.labkey.org/issues/home/Developer/issues/details.view?issueId=22304) has been successfully fixed/resolved for the 15.1 release (build r36050) and I've confirmed the fix on my local machine.

The following has been done:

1. Within the Study under the Manage tab > Repository Type > Change Repository Type, if the repository type is "Advanced" and "Editable", you will see a "Specimen Detail" link that will take you into the Query view for the SpecimenDetail and allow you to select multiple rows of specimens (regardless if they have vials or not) and delete them.

2. The Delete button has been removed on the Individual Vials view. This is to avoid any confusion from the previous item mentioned above.

The reason for this approach is to avoid changing things for most users. (i.e. It would be confusing to allow a non-requestable vial to be selected and requested, yielding an error. Enabling the checkboxes and then catching the error earlier could be a lot of work.)

This will allow you to now delete specimen records without having the need for vials.

Let me know if you have any further questions.

Regards,

Jon