Hard to find as much info regarding the SF match online as NRMP charting match outcomes, but here's a good place to start.
Looks like 2018 had an avg matched step 1 of 245 and unmatched of 228, which would certainly put you in the latter category. Fortunately, you are also a USMD, which has the highest match percentage of any group, but this doesn't show what the avg. Step of each category is, so they could also just be a higher/comparable Step score.
Perhaps with an otherwise
absolutely amazing application or with taking a gap year for significant research, you'd have a chance, but 2 pending pubs (unless groundbreaking research) is pretty run of the mill and likely on the lower end. You also have Step 2 CK/CS looming ahead which will also change your outcome overall, but likely too little too late for ophtho.
I have seen GI in at least 3 different hospitals. Looks like you could do a good mix of procedural stuff and actual medicine (that was done at all 3, no dedicated scoper at the places I rotated, as they all did inpatient medicine on consult services and outpatient follow up). Tbh I have literally no interest in GI, cause scopes are hella boring (literally sticking tubes in butts all day and looking at feces trying to find bleeding is not my idea of fun) and the only remotely interesting medicine for me in that field is Hepatology, but I know many people to really like scoping and GI as a whole. That being said, its a very competitive subspecialty within internal medicine (probably in the same vein as Cards but with fewer spots). You'd have to start working now.
What you'd need is to improve your Step 2 so that you are a competitive IM applicant and do fairly well across the board in 3rd year/4th year rotations as well as getting good letters of support. As someone with a similar Step 1 and a not much higher Step 2 out of a mid tier USMD program, I can tell you you'll still likely wind up in a university program, but you might be somewhere you don't want to be, and it may be a weaker program overall which might make fellowship match even more difficult down the road. Also, Step doesn't stop affecting you at residency, as fellowships screen Step scores too. A 22x won't put you out of the running entirely as a USMD, but we're already limited to some degree for the foreseeable future.
Research/extracurriculars/community service/work experiences all help too for IM, but none of them are super influential at the end of the day. What might help is finding something that you can do to set you apart. Something that you can get a significant leadership role in, impactful research in a IM subspecialty, or something you can start from the ground up which will actually have some impact or be interesting in some way.
Also, are you higher or lower on the 22x? If applying either field, that third digit can make a big difference. A 229 is a rounding error from an average Step score, a 221 is trash. I got a 223, so I know my score sucks, makes it harder across the board.