A biopsy may be done during either an upper GI endoscopy or a colonoscopy. A biopsy is a removal of cells or tissue. The sample is then examined under a microscope.