My grandmother died of liver cancer and I've experienced jaundice due to hepatitis A and medications. Does liver irritation is related to genetics?

Can be. There are a number of genetic diseases that can cause liver problems. However, it seems your problems were due to hepatitis A and certain medications. Both of these can cause jaundice in patients who don't have any genetic liver disease. The majority of patients with liver cancer develop the cancer in the setting of liver cirrhosis.