Merck & Co. agreed to purchase Imago BioSciences Inc. to gain therapies for bone marrow conditions that lead to overproduction of blood cells, including one drug in mid-stage trials.

Merck will pay $36 a share in cash for South San Francisco-based Imago for a total value of about $1.35 billion. The transaction is expected to close in the first quarter of next year, the companies said in a statement.

Imago is developing therapies for myeloproliferative neoplasms, with one drug called bomedemstat in mid-stage trials for conditions that affect the bone marrow’s production of platelets and red blood cells. The purchase is part of Merck’s search for more treatments for cancer and rare diseases after its deal discussions with Seagen Inc. stalled earlier this year.

“This acquisition of Imago augments our pipeline and strengthens our presence in the growing field of hematology,” Merck CEO Robert Davis said in the statement.

Myeloproliferative neoplasms occur when the bone marrow overproduces red blood cells, platelets, or white cells. The buildup of extra cells may lead to bleeding problems, anemia, infection, fatigue, clotting and other symptoms.

Imago’s bomedemstat is a member of family of proteins that regulate the maturation of blood cells. The oral drug is being tested in multiple trials against essential thrombocythemia, when the bone marrow makes too many platelets, polycythemia vera, an oversupply of red blood cells, and a scarring of the bone marrow called myelofibrosis.